Question: Java You will design and implement two classes, Dice and Player, to simulate the dice and players in a dice game. Each player rols a
Java

You will design and implement two classes, Dice and Player, to simulate the dice and players in a dice game. Each player rols a six-sided dice once and get a score that is the number of dots on the dice face. The player who has a higher score wins otherwise it is a te. The folowing code is a client program that will use the two classes to play the game. Understand the cient program will help you to identify the states and expected behaviours of Dice and Player objects. The Hath, andom 0 method will generate a random value between 0 and 1, which will be useful to generate the number of dots on dice faces. public clasa DiceGane publie atatic void ain (seringt arga) / Create a Dice object Create two Player abjacts Player player1new Player Jahn) Player player2new Player ("Peter" Playera roll the dice playerl.rol1Dice (dice) System.out.printin ("Dice face: "+dice.getFace O) player2.roliDice (dice Syaten.out.println("Dice fsce: "dice.getFace D Display the result if (playeri.getsoore >player2.get8core System.out.printin (playerl.getNane 0"wins! Systen.out-printin (player2.getNamewins!) Systea.out.printin( It s a tie!)1 t else The followings are two sample runs of the DiceGane program. $Java DiceCane Dice face: 5 Dice face: 3 John wins $Java DiceGame Dice face: 2 Dice face: 4 Peter wins
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
