You are working for an online gaming company. You have been asked to write some code to supportonline card games, such as poker, gin rummy, other games. As a starting point, you have been asked towrite prototype code that does the following:• Create a deck of cardso There 10 card values, numbered 0 through 9, and there are four cards for each cardvalueo You do not need to track suits (e.g., hearts, spades, etc.); for the purposes of thisassignment, all cards with the same card value are equivalent.• Deal a set of hands to a set of playerso There are five cards per hand and four players per game• Record counts of the multiples and singletons for the cards in each hand (four of a kind, three ofa kind, pairs, singletons, etc.)• Store the state of the deck, hands, and hand counts in a set of arrayso These will be used and updated over the course of games, so simply printing the state ofcards and hands at the start of the game is not sufficient. Instructions: 1. create a set of integer constants, with the following names and values: o deck length: 10 o cards per value: 4 o hand size: 5 o player count: 4

Respuesta :

You are working for an online gaming company. You have been asked to write some code to support online card games, such as poker, gin rummy, other games. Below is the code structure

What is code?

The set of instructions or set of rules written in a specific programming language are referred to as "computer code" in computer programming (i.e., the source code).

Additionally, it refers to the source code that has undergone compilation and is now prepared for computer execution (i.e., the object code).

Below is the code structure

Code:

package com.test.Chegg;

import java.util.Arrays;

import java.util.Random;

public class CardGame {

   static int DECK_LENGTH = 10;

   static int CARD_PER_VALUE = 4;

   static int PLAYER_COUNT = 4;

   static int HAND_SIZE = 5;

   static int[] deck = new int[DECK_LENGTH];

   static int[][] playerHands = new int[PLAYER_COUNT][HAND_SIZE];

   public static void main(String[] args) {

       Arrays.fill(deck, CARD_PER_VALUE);// initializing deck with CARD_PER_VALUE

       // filling playerHands with Random card picked

       for (int i = 0; i < PLAYER_COUNT; i++) {

           for (int j = 0; j < HAND_SIZE; j++) {

               int randomCardValue = getRandom();

               playerHands[i][j] = randomCardValue;

           }

       }

       // printing the hands for each player

       for (int i = 0; i < PLAYER_COUNT; i++) {

           System.out.print("Player " + (i + 1) + " hand : ");

           for (int j = 0; j < HAND_SIZE; j++) {

               System.out.print(playerHands[i][j] + " ");

           }

           System.out.println("");

       }

       // printing the remaining cards

       System.out.println("");

       System.out.println("Cards Remaining:");

       System.out.print("Card:  ");

       for (int i = 0; i < DECK_LENGTH; i++) {

           System.out.print(i + " ");

       }

       System.out.println("");

       System.out.print("Count: ");

       for (int i = 0; i < DECK_LENGTH; i++) {

           System.out.print(deck[i] + " ");

       }

   }

   // function to select random card fro available cards

   private static int getRandom() {

       // TODO Auto-generated method stub

       int randomCardValue = 0;

       for (int i = 0; i < DECK_LENGTH; i++) {

           Random random = new Random();

           randomCardValue = random.nextInt(DECK_LENGTH);

           if (deck[randomCardValue] == 0) {

               continue;

           } else {

               deck[randomCardValue]--;

               break;

           }

       }

       return randomCardValue;

   }

}

Learn more about code

https://brainly.com/question/26134656

#SPJ4