Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a Java class called Die with the following features: an instance variable that can store a whole number value from 1 through 6. a

Implement a Java class calledDiewith the following features:

  • an instance variable that can store a whole number value from 1 through 6.
  • a constructor that assigns a randomvalidvalue to a die object.
  • a method that will roll a die, assigning it a newvalidvalue.
  • a method that returns a die's value.

Implement a dice game called Guess wherein the player chooses a number between 2 and 12 - this is the range of possible values that can be achieved by summing the result of rolling a pair of dice. This dice game will be in its own class calledGuess; it will not be in the Die class.

The game then creates two die objects and rolls them together up to three times. If the player's number comes up when summing the result of rolling the pair of dice, the player wins and the game ends. If, after three rolls of the pair of dice, the player's number has not come up, the computer wins and the game ends.

Create output charting the progress of the game and the result.

Implement a dice game calledMatador. The Matador game will be in its own class called Matador; it will not be in the Die class or in the Guess class.

Here are the rules of Matador:

  • The game is played between the player and the computer.
  • The player's score and the computer's score each begin at 0.
  • The object of the game is to be the first reach 121 points.
  • The player and the computer take turns. On each turn:
  1. The player / computer chooses a number from 2 through 6
  • prompt the player to enter their choice on the keyboard
  • the computer should choose randomly
  1. The player / computer rolls two dice. Determine the results for the player / computer (depending on who is rolling):
  • if a 1 appears on both dice, their score is reset to 0 and it becomes the other's turn.
  • if a 1 appears on only one die, nothing is added to their score and it becomes the other's turn.
  • if a 1 does not appear on either die, the sum of the two dice is added to the roller's score.
  • if their chosen number appears on only one die, they roll again.
  • if their chosen number appears on both dice, they win.
  • if their chosen number did not appear on either die, it becomes the other's turn.

The first to reach a total score of 121 wins.Create output charting the progress of the game and the result.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

Are Costco's prices too low? Why or why not?

Answered: 1 week ago