Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NEED HELP LOST on how to finish my code package project1; import java.util.*; public class Boxone { public static void main(String[] args) { // TODO

NEED HELP LOST on how to finish my code

package project1;

import java.util.*;

public class Boxone {

public static void main(String[] args) {

// TODO Auto-generated method stub

Scanner input = new Scanner(System.in);

System.out.println(" Welcome to the Java Dice Game, Lock N Roll! "

+ "The object of the game is to roll 3 dice and earn the most points. "

+ "Player earns points by maximizing the sum of the dice and earning bonus points. "

+ "Bonus points are earned when rolling a pair, triples, or a straight: "

+ " o Pair Bonus: 2 points "

+ " o Triple Bonus: 30 points "

+ " o Straight Bonus: 10 points "

+ "Player gets 2 rolls. After the first roll, player chooses to either "

+ "\"Lock\" or \"Roll\" a die again, for each of the 3 dice. "

+ "Scoring for the turn is complete after the second roll. "

+ "Enter your name to begin this fast-action game, and let's LOCK N ROLL! ");

System.out.print("Name: ");

String newPlayer = input.next();

System.out.print("How many turns would you like? ");

Double numOfTurns = input.nextDouble();

System.out.println(" " + "************** Begin Turn 1 *************** " + " ");

} //End of main method

public static double sortDice {

} //End of sortDice

public static double checkForPair {

} //End of evaluateIfPair

public static double checkForStraight {

} //End of evaluateIfStraight

public static double checkForTriple {

} //End of evaluateIfSTriple

public static double printTurnHistory {

} //End of printTurnHistory

Create a Java based program that is based on the simulated roll of 3 dice.

  • Player scores points based on the combination of (1) the sum of the dice and (2) bonus points from rolling a pair, a triple, or a straight (3 numbers in a row).
  • Player rolls 3 dice in the first roll, and then decides for each die whether to roll again or stop the value of a die in order to improve the score hence, the name Stop N Roll.
  • At the beginning of the game, player will enter his/her name and the number of turns they wish to have in a single game. A turn is an initial roll plus the second roll after Stop/reroll.
  • After all turns have been played, the program will print a history of the turns showing the players initial roll score, final roll score, and the improvement after the Stop N Roll action.
  • Player is prompted to play again or not.

Functional Requirements

  • System displays the rules of the game on the console.
  • Player enters his/her name.
  • Player enters the number of turns to be taken in the game. A turn consists of the initial role and the second (final) roll.
  • System displays the initial roll including values of the 3 dice, sum of the 3 dice, bonus points, and total points.
  • System indicates progression to the Stop N Roll phase.
  • Player indicates Stop or Roll for each die. Player can stop 0 to 3 dice or roll 0 to 3 dice.
  • After Stop N Roll, die/dice designated for Roll are rolled for new value(s).
  • System analyzes the new set of dice to determine bonus points.
  • System displays the second roll including values of the 3 dice, sum of the 3 dice, bonus points, and total points. If all dice were stopped, the values from the initial roll are the values for the second roll. Turn is completed.
  • If turn completion is not the last turn in the game, a new turn begins starting with the initial roll.
  • If turn completion marks the last turn in the game, system displays the turn history, including initial and final dice values, final sum, final bonus points, final total points, and points improved from initial to final roll for each turn in the game.
  • Player is prompted to indicate whether to play again or not, and responds with Y or N.

Technical Requirements

The system should include the following Java components:

  • System consists of 5 phases. Use this in your Design discussion.
    1. Introduction and printing the rules to console.
    2. Initial roll of the 3 dice.
    3. Stop N Roll, where player indicates whether to stop or roll each die.
    4. Second roll after the Stop N Roll, including final score of the turn. This includes end of the turn, printing of turn results, and triggers the start of the next turn (phase 2 again, if another turn is required).
    5. After turns in the game are completed, system prints to console a summary of the players performance for each turn.
      • Final dice values for both rolls.
      • Final sum, pair, triple, straight values.
      • Final roll total points.
      • Points improved from initial to final roll.
  • Variables (other than local vars) should be declared at the beginning of the main method.
  • Use arrays for storing of dice values, e.g., int[] roll1 = new int[3];
  • Methods to implement for the following functions.
    • Sort the dice.
    • Evaluate dice values for a pair.
    • Evaluate dice values for a triple.
      • Note: if dice indicate a triple, then no pair bonus is earned.
    • Evaluate dice values for a straight.
    • Print turn history at end of game.
  • while or for loop to execute the indicated number of turns.
  • Algorithm for generating the random die values using Random class.
  • System.out.printf() method for formatting of printing turn, roll, and game results.
  • String array to store the values associated with each turn.
  • do-while loop to enable continuous play with Y/N response.
  • for loops for various activities updating dice values, printing of turn history, etc. especially for those associated with arrays.

EXAMPLE OUTPUT THAT NEEDS TO WORK IN THE CODE:

Enter your name to begin this fast-action game, and let's STOP N ROLL!

Name: Alexander

How many turns would you like in this game? 2

************** Begin Turn 1***************

1 2 3 Sum Pair Trip Strait Points

-- -- -- --- ---- ---- --- ---

Roll-1 2 4 4 10 2 0 0 12

Now it's time to STOP N ROLL!

Die1 value: 2 Enter L or R: r

Die2 value: 4 Enter L or R: l

Die3 value: 4 Enter L or R: l

1 2 3 Sum Pair Trip Strait Total

-- -- -- --- ---- ---- ---- ----

Roll-2 4 4 4 12 0 30 0 42

--Roll1-- --Roll2-- Sum Pair Trip Strait Total Imprv

-- -- -- -- -- -- --- ---- ---- ---- ---- ----

Turn-1 2 4 4 4 4 4 12 0 30 0 42 30

**************************************************************

************** Begin Turn 2***************

1 2 3 Sum Pair Trip Strait Points

-- -- -- --- ---- ---- --- ---

Roll-1 2 4 6 12 0 0 0 12

Now it's time to STOP N ROLL!

Die1 value: 2 Enter L or R: r

Die2 value: 4 Enter L or R: l

Die3 value: 6 Enter L or R: l

1 2 3 Sum Pair Trip Strait Total

-- -- -- --- ---- ---- ---- ----

Roll-2 1 4 6 11 0 0 0 11

--Roll1-- --Roll2-- Sum Pair Trip Strait Total Imprv

-- -- -- -- -- -- --- ---- ---- ---- ---- ----

Turn-2 2 4 6 1 4 6 11 0 0 0 11 -1

**************************************************************

Turn History for this session

ALEXANDER 2021-02-02-20-38-33 Turn-1 2 4 4 4 4 4 Pts: 42 Imprv: 30

ALEXANDER 2021-02-02-20-38-33 Turn-2 2 4 6 1 4 6 Pts: 11 Imprv: -1

Would you like to play again? Enter Y or N: n

Thanks for playing, Alexander! Come back and play again soon!

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago