In the dice game Strike Out, the goal is to win 200 points before rolling the strike-out sum three times.
public Die() Creates a standard six-side die.public int roll() Rolls the die and returns the number of spots on the face of the die.
****************************** Strikes: 1 Your total points: 35 ******************************
You should use names for your variables that are self-documenting (i.e. its name explains what the variable stores like "score" rather than "i") and indent your code using proper Java style. Include additional comments if you feel you need to explain your code.
Sample Program Execution #1 (User input shown in bold italics.)
Welcome to the STRIKE OUT game Please enter an integer (1-6): 5 The STRIKE-OUT SUM is 7 You rolled 5 2 STRIKE-OUT SUM! You get a strike! You get 0 points ****************************** Strikes: 1 Your total points: 0 ****************************** You rolled 1 6 STRIKE-OUT SUM! You get a strike! You get 0 points ****************************** Strikes: 2 Your total points: 0 ****************************** You rolled 6 2 You get 12 points ****************************** Strikes: 2 Your total points: 12 ****************************** You rolled 3 6 You get 18 points ****************************** Strikes: 2 Your total points: 30 ****************************** You rolled 2 2 You get 20 points ****************************** Strikes: 2 Your total points: 50 ****************************** You rolled 5 2 STRIKE-OUT SUM! You get a strike! You get 0 points ****************************** Strikes: 3 Your total points: 50 ****************************** SORRY: You struck out.
Sample Program Execution #2
Welcome to the STRIKE OUT game Please enter an integer (1-6): 8 Error: Bad input Please enter an integer (1-6): 0 Error: Bad input Please enter an integer (1-6): 2 The strike out sum is 6 You rolled 3 4 You get 12 points ****************************** Strikes: 0 Your total points: 12 ****************************** You rolled 3 3 STRIKE-OUT SUM! You get a strike! You get 0 points ****************************** Strikes: 1 Your total points: 12 ****************************** You rolled 5 6 You get 30 points ****************************** Strikes: 1 Your total points: 42 ****************************** You rolled 6 2 You get 12 points ****************************** Strikes: 1 Your total points: 54 ****************************** You rolled 5 6 You get 30 points ****************************** Strikes: 1 Your total points: 84 ****************************** You rolled 1 2 You get 2 points ****************************** Strikes: 1 Your total points: 86 ****************************** You rolled 2 2 You get 20 points ****************************** Strikes: 1 Your total points: 106 ****************************** YOU WIN!!