Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java programming a) Create a Die class that have two fields one to represent number of sides and one to represent dies value. The class

Java programming

a) Create a Die class that have two fields one to represent number of sides and one to represent dies value. The class should have a constructor that accepts the number of sides as an argument. The class should have appropriate method for rolling the die and getting the dies value.

b) Create an application named FishingGame that simulates a fishing game. In this game, a six-sided die is rolled to determine what the user has caught. Each possible item is worth a certain number of fishing points. The points will remain hidden until the user is finished fishing, and then a message is displayed congratulating the user, depending on the number of fishing points gained.

Here are some suggestions for the games design:

Each round of the game is performed as an iteration of a loop that repeats as long as the player wants to fish for more items.

At the beginning of each round, the program will ask the user whether or not he or she wants to continue fishing.

The program simulates the rolling of a six-sided die (use the Die class created in part a).

Each item that can be caught is represented by a number generated from the die; for

example, 1 for a huge fish, 2 for an old shoe, 3 for a little fish, and so on.

Each item the user catches is worth a different amount of points.

The loop keeps a running total of the users fishing points.

After the loop has finished, the total number of fishing points is displayed, along with a message that varies depending on the number of points earned.

c) Create an application named DiceGame that simulates a simple dice game. Use the Die class (created in part a) to create a simple dice game in which the user chooses a number between 2 (the lowest total possible) and 12 (the highest total possible). The user rolls two dice up to three times. If the number chosen by the user comes up, the user wins and the game ends. If the number does not come up within three rolls, the computer wins.

Note:

Use a Random class nextInt method to generate random numbers.

User input/output could be console based or GUI based.

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

Database Support For Data Mining Applications Discovering Knowledge With Inductive Queries Lnai 2682

Authors: Rosa Meo ,Pier L. Lanzi ,Mika Klemettinen

2004th Edition

3540224793, 978-3540224792

More Books

Students also viewed these Databases questions

Question

Distinguish between poor and good positive and neutral messages.

Answered: 1 week ago

Question

Describe the four specific guidelines for using the direct plan.

Answered: 1 week ago