Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program that will allow a person to play the game of Skunk against three computer players. Skunk is a dice game that

Write a Java program that will allow a person to play the game of "Skunk" against three computer players. Skunk is a dice game that uses two 6-sided dice. Use random numbers to simulate the dice rolls. The goal of the game is to roll the dice for points and the first person who gets 100 points wins. The player determines how many times they wish to roll the dice during their turn provided they don't get "skunked". Once a player gets skunked, their turn is over and may lose some or all their points as a result. There are two ways to get skunked: One of the two dice can roll a one. This is a "single skunk". In this case the person loses all points that were earned during this turn. Both dice roll a one. This is a "double skunk". In this case the person loses all their points and return to zero points. The player can end their turn at any time after they have made at least one roll. A roll consists of rolling both dice. If a "one" does not appear, the value on both dice are added to the players score. For example, assume player 1 currently has 27 points. The following table will show how the player's turn went: Comments Dice Roll Score Start of turn 27 Roll 1 3 4 34 Roll 2 5 4 43 Roll 3 2 2 47 Roll 4 6 3 56 End of turn 56 Player 1 ends their turn with a score of 56. Assume player 2 currently has 52 points. The following table will show how the player's turn went: Comments Dice Roll Score Start of turn 52 Roll 1 2 5 59 Roll 2 6 1 Single Skunk End of turn 52 Player 2 ends their turn with a score of 52. They lost all points earned this turn because of the single skunk. Assume player 3 currently has 70 points. The following table will show how the player's turn went: Comments Dice Roll Score Start of turn 70 Roll 1 5 4 79 Roll 2 2 3 84 Roll 3 1 1 Double Skunk End turn 0 Player 3 ends their turn with a score of 0, because of the double skunk. The program must have three computer players to play against. The first computer player always ends its turn after 3 rolls (assuming the turn is not ended earlier due to a skunk). The second computer players always ends its turn after it has earned at least 20 points (assuming the turn is not ended earlier due to a skunk). The third computer player always tries to earn 100 points. Its turn is ended only when it gets a skunk. The program must show the points of each of the computer players. It must also describe what happened during their last turn. The user player always goes first. When their turn is over the three computer players get turns (one turn per computer player). When a player wins, output who the winner of the game was. Finally, ask the user if he/she wishes to play the game again Implementation: This program will be less structured than previous assignments. Some classes that will be needed are specified below and additional classes can be used. It is up to the student to figure out what the responsibilities (methods) of each class will be. The following class must be used: Skunk (object) - to represent the entire game. Creating a Skunk object should start the game. Also, no object should directly examine or alter the variables of any other object; all access should be done by talking to (calling methods of) the other object. The student should figure out what the various classes and objects should be and what their instance variables and their methods should be. There is no single "correct" design; any reasonable design will do. The better the design, the easier the programming will be. Use the objects defined to play a game of Skunk. Place all classes into one file. Output should be user friendly.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions