Question: Create a data type to represent a Player in a game of Cribbage. The Player object has a name and a position on the board

 Create a data type to represent a Player in a game

Create a data type to represent a Player in a game of Cribbage. The Player object has a name and a position on the board (an int value). The name cannot be changed. Players always start at position zero. Create a getter for the position. (Do not create a setter.) Create a count method that advances the Player the given number of positions. For example, if the Player was on position 3, the command count(4) would move them to position 7 (3+4 = 7). The count method only accepts numbers in the range 0 to 29. Have the count method throw an IllegalArgumentException if the argument is outside the 0 to 29 range. ALSO have the count method treat 19 as zero for the purpose of advancing (that is, if the player is at position 3, the command count(19) leaves them at position 3). Use good design principles

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!