Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the rollDice method in a DoubleDrat class as described in the instructions below. Create a main method that simply calls the rollDice method for

Write the rollDice method in a DoubleDrat class as described in the instructions below. Create a main method that simply calls the rollDice method for testing. Test that it prints the roll output as shown in the instructions. Also test that it returns the score value by printing the returned value within the main method.

image text in transcribed

image text in transcribed

image text in transcribed

Thank you!

Method Summary main Parameters: n/a Returns: n/a Purpose: Manage the main flow of the game from start to end Call the displaylnstructions method Create players Prompt for number of players Create a String array for player names and an int array for scores Prompt for player names and store in the player names array (Scores will initialize to 0 for each player by creating the int array.) Manage rounds and turns within loops displaylnstructions Parameters: n/a Returns: n/a Purpose: Display welcome message and game instructions. rollDice Parameters: n/a Returns: points earned for the rol! Purpose: Using a random number generator, simulate rolling three 6-sided dice. Determine the score for the rofl and return that score value to the calling method. (Return 30 for triple, 20 for all unique, and 0 for double. Dispay the roll values and the score for the roll such as Rolled: 3 5 4 (roll value 20) Rolled: 3 6 6 (roll value 0) Rolled: 22 2 (roll value 30) takeTurn Parameters: current player name (as a String) Returns: points earned for the completed player's turn Purpose: Display points accumulated so far this turn, and ask player "Roll/Bank(R/B)?". f they choose "R", call the rollDice method and add the the returned score value to the accumulated points for this player's turn f rollDice returns a 0 (double drat), end the player's turn and return 0 to the main method if the player chooses "B", return the accumulated points from this turn to the main method Note: You'll need to create a Scanner in this method to prompt for "R/B". displayScoreboard Parameters: names (String) array and scores (int) array Returns: n/a Purpose: Print a scoreboard header that matches the sample output. Loop through the arrays and print the name and corresponding score for each player using values from the two arrays. Assume that the sort order of the scores array matches the order of the player names array

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions

Question

Explain the importance of nonverbal messages.

Answered: 1 week ago

Question

Describe the advantages of effective listening.

Answered: 1 week ago

Question

Prepare an employment application.

Answered: 1 week ago