I need Some help writing a program in C++ Here are the instructions: Create a do
ID: 3683834 • Letter: I
Question
I need Some help writing a program in C++ Here are the instructions: Create a domino game and table that has the following features 1. Create a Class CRandom to sort dominos that are shown/picked that makes sure pieces arent used twice. 2. Create a Class Ctable to show/display the sorted pieces using class deque as a double ended dynamically sized sequence container. 3. Create a class CDominoes to contain the data structure with pieces 4. Have a class CPlayer to select a randomly picked piece and sequential show the selected pieces 5. For attributes and variables for each piece use a struct named structdata{}..piece as dynamic allocated vector, as to properly allocate and free memory. 6. properly initialize and clean up each class implemented. 7. Make proper initialization and clean up of each class and structure you implemented, accordingly using as needed constructor, destructor, new and delete. 8. Generate a initialization of the pieces as positioned by a random uniform distribution. This initial positioning of the pieces are for the pieces available to be taken by the players as: available pieces. 9. Have two players on table. 10. From the 28 pieces, randomly give 10 pieces for each player. 11. The remaining 8 pieces stay available to be taken if the player doesn't have any piece that will match with the current head and tail of the game already placed on table thus, the player takes a piece from the so called available pieces. 12. Check if from the pieces in the current player's hand, if current player can select a piece that will match the tail or the head of the matching game. If not, then this player should take a piece from the available pieces. Then, check again if now this player can match this newly taken piece to the head or tail of the dominoes match; if not, the player goes and take another piece from available pieces. Repeat it until the player can match some of new piece into the dominoes tail or head. In case the player has no longer any left piece to take from available pieces, then the time to play turns to the other player. 13. The side of the piece placed on the head or tail of the dominoes match is marked as no longer available value to matching a next piece to be added on the matching table; at the same time the other value available in this piece become visible as the new head or tail from the dominoes match, that just become available as the new value to be matched to the next piece to be played, as the head or tail accordingly. 14. The first person to play is defined by a random uniform distribution. 15. The winner is who places all his pieces on the table, matching the head and the tail on the game with his pieces after playing each of his turns, and is left with no additional pieces in his hand. 16. Display in ASCII format on console each move from each player. Display in ASCII format on console the final result: who won, how many pieces was left with the second placed player and which are these pieces; the dominoes matching pieces as they were matching and placed on table.
Explanation / Answer
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author vista */ import java.util.*; import javax.swing.JOptionPane; class Variables { static Dice dice=new Dice (49); static tiles tile=new tiles(); static String [] character=new String[3]; static int charcount=0; static int player1[][]=new int[2][49]; static int player2[][]=new int[2][49]; static int dicevalue; static boolean check; static boolean checkroll; static boolean checkroll1; static boolean checkgame=true; static int highhead1=0; static int highhead2=0; static int hightail1=0; static int hightail2=0; static int interval[][]=new int[2][98]; static int x2=49; static int y2=49; static int xx2=49; static int yy2=49; static int toplace; static int counter1; static int counterplayer1; static int counterplayer2; static int temp; } class Dice { Random r =new Random(); int sides; //constructor public Dice(int s){ sides = s; } //roll method depending on sides up there public int roll(){ return r.nextInt(sides); } } class tiles { static int headcount=0; static int tailcount=0; static int a=0; static int b=0; int handler[][]=new int [2][49]; public void dominotiles(){ for(int x=0;xRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.