Question
Using Java, code a DartGame class DartGame class The DartGame class will manage the playing of a Dart Game . It will have the following
Using Java, code a DartGame class
DartGame class
The DartGame class will manage the playing of a Dart Game. It will have the following fields (at least):
Player - an object of type Player
The DartGame class will have methods to manage the playing of the game. These should include the main() method to start the program and methods for the following behaviours (at least):
-Display a welcome message on the screen.
-Request the player to enter their name.
-Request the player to enter the number of darts they wish to throw for the game.
-Calculate the score for a dart throw.
-Display the result of a dart throw.
-Display the result for the end the game.
The human player is invited to throw the first dart. The game then progresses, with Dart Vader (the computer) throwing the next dart, then the players taking turns until all the darts have been thrown. Note that your program will generate a dart throw for each of Dart Vader's turns.
The following are the possible outcomes when a dart is thrown:
-the dart will land on the board (pi/4*100) percent of the throws. If the dart does not land on the board (i.e., it lands on the grey area instead) then 0 (zero) is scored.
if the dart lands on the board then:
there is a 4% chance the dart will land in the black area. The player scores 5 points.
there is a 16% chance it will land in the yellow area. The player scores 2 points.
there is a 80% chance it will land in the blue area. The player scores 1 point.
When invited to throw a dart the human player may instead decide to abandon the game. Dart Vader will decide to abandon the game randomly on 5% of the throws.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started