Would You Like to Play Again Method Java and Implementation
Practice Overview Implement a Java program that simulates the...
Exercise Overview
Implement a Coffee program that simulates the rolling of ii dice and so evaluates the dice gyre to determine points scored based on the game's rules. Total points are the sum of the two dice plus bonus points for rolling a pair, a vii, or an xi.
- Actor starts the game by inbound their name.
- Player enters the number of turns (rolls) they wish to take in the game.
- Histrion rolls the dice.
- The system shows the points scored based on the roll and the bonus signal rules.
- Game repeats for the designated number of turns.
- Player has the option to play again.
Functional Requirements (how the code will work from the user perspective)
- System prompts the role player for their name and reads the input via Scanner.
- System displays a welcome bulletin to the user on the console, including the user's name, and prints the rules of the game.
- System prompts the user to brainstorm the game.
- Player is prompted for and enters in the number of turns (rolls) they with to play for their game.
- System rolls the dice and displays the dice values.
- Organisation evaluates the dice values and calculates total score.
- Score components are printed on the panel.
- The roll of the dice, evaluation, and score press is repeated for the number of turns designated.
- Player is prompted as to whether they wish to play again.
- Cease the game by printing an end-of-game bulletin.
Technical Requirements (how you lot must code it)
The system should include the following Coffee components:
- 3 classes - Commuter ([your_name]_Project_5), Game, and Session.
- Driver class. Contains the primary method and instantiates and uses objects from the other two classes.
- Commuter class instantiates objects, includes the practise-while loop, invokes methods on the objects.
- Instantiate objects from Scanner (input), Game (game), and Session (session).
- Declare variables. There is only the String playAgain variable.
- Invoke pre-game methods, session.getName and session.prtIntro.
- Initiate the practice-while loop with variable playAgain.
- Invoke the session.setTurns method to prompt for, read-in, and shop the number of turns.
- Initiate a for loop or while loop to manage the number of turns played.
- Employ playAgain to prompt for and read-in Y or N to stay in or get out the do-while loop.
- Invoke prtOutro method.
- Commuter class instantiates objects, includes the practise-while loop, invokes methods on the objects.
- Game class. Includes most of the variables and methods that were used in Project iii, just with some modifications.
- Game grade includes the variables and methods associated with the dice game, and has the major sections, Instantiate Objects, Declare Variables, Define Constructors, and Ascertain Methods.
- Instantiate Objects
- The Game class must instantiate a Random (random) object.
- Declare Variables.
- All variables alleged in Game form must have a individual visibility modifier.
- die1, die2
- sum
- pairBonus
- seven11Bonus
- full
- tempDie
- Define Constructors.
- No explicit constructors demand exist divers but include a section annotate for Define Constructors with no constructors listed.
- Define Methods.
- setDice - assigns the random int values to die1 and die2, and assigns the value to the variable sum.
- sortDice - sequences the dice so that the value of die1 is less than or equal to the value of die2.
- getDie1 - returns the die1 value.
- getDie2 - returns the die2 value.
- getSum - returns the sum value.
- setPairBonus - evaluates the dice for a pair bonus and sets the variable pairBonus to either 0 or 6.
- getPairBonus - returns the value of the var pairBonus.
- setSeven11Bonus - evaluates the dice for seven-11 bonus and sets the variable seven11Bonus to either 0 or five.
- getSeven11Bonus - returns the value of the variable seven11Bonus.
- setTotal - sets the variable full to the sum of the variables sum, pairBonus, and seven11Bonus.
- getTotal - returns the value of the variable total.
- Instantiate Objects
- Game grade includes the variables and methods associated with the dice game, and has the major sections, Instantiate Objects, Declare Variables, Define Constructors, and Ascertain Methods.
- Session class. Includes the administrative variables and methods associated with the player's session.
- Session class includes the variables and methods associated with the direction of the actor'southward session and has the major sections, Instantiate Objects, Declare Variables, Define Constructors, and Define Methods.
- Instantiate Objects
- The Session class must instantiate a Scanner(scan) object.
- Declare Variables
- All variables declared in Session class must have a private visibility modifier.
- String proper name
- int turns
- Define Constructors
- No explicit constructors demand be divers simply include a department comment for Define Constructors with no constructors listed.
- Define Methods
- setName - prompts for, reads in, and assigns the value to the variable name.
- prtIntro - prints the intro message.
- setTurns - prompts for, reads in, and assigns the value to the variable turns.
- getTurns - returns the value of the variable turns.
- prtOutro - prints the outro message.
- Instantiate Objects
- Session class includes the variables and methods associated with the direction of the actor'southward session and has the major sections, Instantiate Objects, Declare Variables, Define Constructors, and Define Methods.
- Name your source lawmaking main class (.java file) every bit YourName _Project5.java
Example output(from the Eclipse console)
Prototype transcription text
Please enter your proper name: Kevin Hi, Kevin. welcome to the 3311 Dice Game! Playing the game is easy - just "scroll" the dice and the calculator does the rest. The sum of the die is worth points. Y'all earn five bonus if you roll a 7 or 11. Yous earn 6 bonus points if you gyre doubles. Now let'due south begin - enter whatever character key to begin. How many turns would yous like: 3 I
Image transcription text
##v## Turn 1 ##5## Dice Roll: 3,five Die Sum: 8 Pair Bonus: vii-11 Bonus: Total Pts: MOO *** Turn 2 ** Dice Roll: 2 Dice Sum: 5 Pair Bonus: 9 vii-11 Bonus: 8 Total Pts: v ##5## Plough 3 ##v## Dice Roll: 1,six Dice Sum: 7 Pair Bonus: six 7-11 Bonus: 5 Total Pts: 12
Prototype transcription text
How many turns would you like: ii flfilfl Turn 1 ##3## Dice Ringlet: iv,six Dice Sum: 18 Pair Bonus: 8 7-11 Bonus: viii Full Pts: 18 {- *** Plow 2 * Dice Gyre: Die Sum: Pair Bonus: ?-11 Bonus: Total Pts: I. g mmmmm {- would yous like to play once again? Enter Y or Due north: n Thank y'all for playing 3311 Dice Game, Kevin. Come dorsum and play once again any time!
Reply & Explanation
Solved past verified proficient
acinia pulvinar tortor nec facilisis. Pellentesqu
ctum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus dues, dapibus a molestie consequat, ultrices air conditioning magna. Fusce dui lectus, congue vel laoreet
Unlock total access to Course Hero
Explore over 16 million stride-by-step answers from our library
Subscribe to view answer
Step-by-step explanation
nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat,
gue
south a mol
cing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit down amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie conseq
gue
icitur laoree
at, ultrices ac magna. Fusce dui lectus, congue vel laoreet air conditioning, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit down amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit down amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices air-conditioning magna. Fusce dui lectus, congue vel laoreet air conditioning, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices air-conditioning magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit down amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices air-conditioning magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices air conditioning magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec al
gue
s ante, dapibus a moles
dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices air-conditioning magna. Fusce dui lect
gue
itur laoree
risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices air-conditioning magna. Fusce dui lectus, congue vel laoreet air-conditioning, dictum vitae odio. Donec aliquet. Lorem ipsum practice
gue
gue
ec facilisis. Pellentesque
gue
gue
williamsmaysinger.blogspot.com
Source: https://www.coursehero.com/tutors-problems/Java-Programming/39943729-Exercise-Overview-Implement-a-Java-program-that-simulates-the/
0 Response to "Would You Like to Play Again Method Java and Implementation"
Post a Comment