Question: Please use Java to code and complete the assignment Task Create a Java program to simulate a simplified game of Dominoes between the user and

Please use Java to code and complete the assignment
 Please use Java to code and complete the assignment Task Create
a Java program to simulate a simplified game of Dominoes between the

Task Create a Java program to simulate a simplified game of Dominoes between the user and the computer A domino has two ends each of which contains a number of dots between 0 and 6. A set of dominoes is all such dominoes (there are 28). In a game of Dominoes, players take turns laying dominoes to form a long chain. Each player gets 7 dominoes to start and each player must play a domino from his/her hand that matches one of the ends of the domino chain. If a player has no match they draw another domino from the unused ones (if any remain). The winner is the first player left with no dominoes Method 1. Create a Domino class to encapsulate a domino. The class has two private instance variables- num1 and num2, representing the two ends of the domino. You must also include the following methods: . . e Constructor and a copy constructor getNum1(), getNum2( ), setNum1(n) and setNum2(n) toString that will return a String representing a domino equals that compares this to another Domino and returns a boolean swapNumbers that swaps the num1 and num2 instance variables getValue() that returns the sum of the ends of the domino . a DominoGroup class to represent any group of dominoes (not necessarily a whole set). The class should have two private instance variables- an array of Dominos and numDominoes an int to store how many dominoes in the group. Note: the constructor will instantiate the array to be size 28. Any DominoGroup object will have as many entries filled as necessary- the rest will be empty. You must include the following methods Constructor that creates an empty set of Dominoes. It should set numDominoes to O and instantiate an array of 28 entries but fill none of them. setNumDominoes(n) and getNumDominoes() getDominoi) - returns domino at position i setDominofi, d)-sets domino at position i to Dominod makeDominoSet - adds all 28 dominoes to an existing empty DominoG mix-randomizes the order of the dominoes in the DominoGroup addDominoFront(d)- adds Domino d to the front of the DominoGroup addDominoBack(d) --adds Domino d to the back of the DominoGroup removeDomino() -removes (and returns) the domino at position i (close gap in array adjust numDominoes) toString-return String list of all dominoes in the object. Create a class called DominoTest to test your two classes. This DominoTest class should just have a main that does the following: Instantiate an empty DominoGroup object Put the 28 different dominoes into this object (use makeDominoSet method) Print the DominoGroup object (use System.out.print) Mix the DominoGroup object (use mix method) Print the DominoGroup object (cont.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!