Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project: Project 2 Lock N Roll_OOP Total Points Possible: 40 pts Estimated time to complete: 4-8 hours Exercise Overview Implement a Java program that is

Project: Project 2 Lock N Roll_OOP

Total Points Possible: 40 pts

Estimated time to complete: 4-8 hours

Exercise Overview

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

You are to develop the system using object-oriented programming techniques (objects and classes). (NEW)

  • 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 lock the value of a die to improve the score hence, the name Lock 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 lock/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 Lock N Roll action.
  • Player is prompted to play again or not.

Functional Requirements (how the code will work from the user perspective)

  • 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 Lock N Roll phase.
  • Player indicates Lock or Roll for each die. Player can lock 0 to 3 dice or roll 0 to 3 dice.
  • After Lock 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 locked, 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.

Additional Functional Requirements for Project 2 (NEW)

  • Rules must be printed at the beginning of the game and before the name prompt.
  • Entered values must be entered on the same line as the prompt (use System.out.print(); rather than System.out.println(); ).
    • For example: Enter your name: Kevin
  • System must accept entered letters, such as L, R, Y, N, in either uppercase or lowercase.
    • Use the String method, toUppercase(), e.g., yesNo = yesNo.toUpperCase();
  • Dice roll must be sorted for presentation and when choosing L or R. Use Arrays.sort();
  • Headers must be aligned over columns when presenting roll and point values.

Technical Requirements (how you must code it)

The system should include the following Java components:

  • System must consist of a Driver class and at least 2 object classes, such as Roll and Turn, or Roll, Turn, and Game. (NEW)
  • System should be submitted in one .java file, with the Driver class first followed by object classes.
  • Name of your source code main class as follows: YourName_Project2.java
  • Object classes must be organized as follows: (NEW)
    • Variables declared at the beginning of the class.
      • Exception is local vars, such as int i in a for loop, or temp vars in a method.
    • Constructors follow variables.
    • Methods follow constructors.
  • All data variables in the object classes have a visibility of private. (NEW)
    • This will require you to use setter and getter methods for these variables.
  • All methods in the object classes have a visibility of public and are not static. (NEW)
  • Use arrays for storing of dice values, e.g., int[] roll1 = new int[3];
  • 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.

Additional Technical Requirements for Project 2 (NEW)

  • You are to start with your Project 1 code base and refactor that Project 1 code into an object-oriented programming design.
  • Alternatively, you can use the solution code base provided for Project 1 as your starting point, and refactor that into an object-oriented programming design.

Hints and Suggestions

  • Read the submission instructions and grading rubric at the end of this document.
  • While writing code, print variable values to console frequently as a form of testing.
  • Use comments to label the different sections (and subsections) of your code.

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

Handbook Of Database Security Applications And Trends

Authors: Michael Gertz, Sushil Jajodia

1st Edition

1441943056, 978-1441943057

More Books

Students also viewed these Databases questions

Question

what definition describes the program managnent process?

Answered: 1 week ago

Question

4. Who should be invited to attend?

Answered: 1 week ago

Question

7. How will you encourage her to report back on the findings?

Answered: 1 week ago