Project 2 – LockNRoll_OOP Overview How should I organize my classes? · Consider 2 things: data and tasks/activities · Keep related things together in the same class Design Analysis – Project 2 · Data...

1 answer below »
please see attachment


Project 2 – LockNRoll_OOP Overview How should I organize my classes? · Consider 2 things: data and tasks/activities · Keep related things together in the same class Design Analysis – Project 2 · Data groupings · Dice values – lowest level of data · Roll summary and point calculations – sum, bonuses, total points · Turn summary · Turn history for a game · Activities · Get inputs for name and number of turns · get dice roll 1 · Evaluate dice roll 1 · Get L/R entries · Get dice roll 2 · Evaluate dice roll 2 · Create turn summary · Create/update turn history · Define your classes in writing · Write out in words the purpose of the class · Create a UML Class diagram (or something similar) How or where do I start? · Create your .java files – Driver and whatever object classes you initially decide on · Copy your list of data variable declarations from Project 1 into each of the object classes · Comment out those that likely do not belong in each of the object classes · If you are not sure if a var belongs in a class, make a comment to the right of the var · Outline your Driver class with comment lines representing the code tasks that follow the sequence of events · As you identify code tasks in your outline, if a code task likely belongs in an object class, add a comment for that code task in the object class – it will likely be a method in the object class · After completing the outline, begin to move complete/near-complete code sections from Project 1 to the designated spot in the outline, either in Driver or in an object class · Methods in your Project 1 class should have a logical place in a Project 2 object class · Working top down, begin to implement the code, starting in the Driver class · Invoke constructors at/near the beginning – use default constructors as a starting point · Add new constructors as required as the code develops · As you reach a point in Driver where it would be logical/appropriate to invoke a method in an object class, · Write the invocation statement in Driver · Implement the method in the object class · Test frequently using throw-away code · Print output to the console · Mark the throw-away code with a comment, such as // TEMP **************** so you can easily go back and delete it when you no longer need it · As you update and/or need variables from object classes, add setter/getter methods · You might want to create a getter method immediately after you create a setter method, so it is there when you need it Suggestions and Warnings · Be willing to adjust your design as you progress · Perhaps your choice of object classes needs to be changed – e.g., add another object class or eliminate an object class and combine move the code to another object class · In the early stages of your development, such as the outline, do not get overly detailed · You can add detail later · You need to get the big picture completed from start to finish · Do not fret over constructors. · Start with default constructors · Add explicit constructors later when you realize it is needed and/or when you are streamlining your code · Be sure to allow time for streamlining of your code · Initial code implementations are rarely highly efficient or elegant (simple) · Evaluate sections of code to determine if there is a more efficient / elegant way · Evaluate your comments and make sure you have comments are consistent and useful · Delete the throw-away code and for-testing-only code Warnings · Object class tedium can be caused by the following: · Creating getter and setter methods in object class because of private data vars · Remembering to use object names when invoking object class methods · Don’t get frustrated. You will get the hang of it!! · Plan data var and classes before you start coding – use the UML Class template · If you know the class where the data var belongs: · You will know in which class to write the methods · You will know how to access the data in the Driver class (via object class methods) · Getter versus Setter Methods and return type · If you need a return from your method, it is most likely a getter method · If you do not need a return (return type is void), it is likely a setter method Name:_______________________ ITSS / OPRE 3312 – Object-Oriented Programming Instructor – Kevin Short 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 player’s 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. Students to complete and submit the following sections Student Name: Class and Section: Project: Example output (from the Eclipse console) Research and Analysis. Describe the problem including input, processing, primary calculations, and output in your own words (5 pts). Type response here. Design. Describe the major steps for solving the problem (5 pts). Type response here. Coding. Source code (25 pts). Submit your source code (your .java file) as a second file when you submit your project. Testing. Describe how you tested this program (5 pts). Include descriptions of testing for specific calculations and/or algorithms, methods, and logic
Answered 7 days AfterFeb 25, 2021

Answer To: Project 2 – LockNRoll_OOP Overview How should I organize my classes? · Consider 2 things: data and...

Pulkit answered on Feb 27 2021
139 Votes
Students to complete and submit the following sections
Student Name:     
Class and Section:
Project:
Example output (from the Eclipse console)
Research and Analysis.
Problem is based on random in
teger function, Object oriented programming concepts like I have to made classes for every classes I have to make objects. And concepts of Inheritance, Polymorphism and Abstraction is also included. I have to make public and private method in this problem with the help of constructors. Problem is based on a player rolls a 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.
Let’s talk about input first. At first, user have to give input of his name. Then, he will enter the numbers of turn he want to play in that game. It is done by random generator function which generates random number in the dice. He will roll dice 3 dice in the first roll and then again decider whether he have to roll again or not.
Next point is processing and primary calculations. It is very simple to calculate and process the program. As I mentioned earlier, problem will be processed on different classes. Let’s understand step by step. First, I have to make array of the user input in which all no of dice will be stored. Then I have to double the size of the array for the random integers to store the total no of integers generated by the program. So, my next step is calculations, Player scores points based on the combination of (1) the sum of the dice and (2) points from rolling a pair, a triple, or a straight (3 numbers in a row) that’s how I calculate the primary calculations.
Last one is output, after taking the input from the user and do all the processing, primary calculations I have to shown the output of this function. Basically, the program will print a history of the turn of the player which includes the player’s initial roll score, final roll score and the improvement after the Lock N Roll action. In the last, program will ask user...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here