Question: please generate code using either previous code or a new one as long as it follows all requirements, thank you COPIABLE CODE: Package project1; import

please generate code using either previous code or a new one as long as it follows all requirements, thank you
COPIABLE CODE:
Package project1; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Arrays; import java.util.Random; import java.util.Scanner; public class Project1_LockNRoll { public static void main(String[] args) { // TODO Auto-generated method stub// Variables **************************************** String name; int turns; int cntTurns; String dateTimeFormat; String[] turnHist; int[] roll1 = new int[3]; int[] roll2 = new int[3]; int sum; int pairBonus; int tripBonus; int strBonus; int points1; int points2; String[] dieLR = new String[3]; boolean reRoll = false; String yesNo; boolean playAgain = false; // Introduction and Rules *************************** System.out.println(" Welcome to the Java Dice Game, Lock N Roll!"); System.out.println("The object of the game is to roll 3 dice and earn the most points."); System.out.println("Player earns points by maximizing the sum of the dice and " + "earning bonus points."); System.out.println("Bonus points are earned when rolling a pair, triples, or a straight:"); System.out.println(" o Pair Bonus: 2 points"); System.out.println(" o Triple Bonus: 30 points"); System.out.println(" o Straight Bonus: 10 points"); System.out.println("Player gets 2 rolls. After the first roll, player chooses to either"); System.out.println("\"Lock\" or \"Roll\" a die again, for each of the 3 dice."); System.out.println("Scoring for the turn is complete after the second roll."); System.out.println(); // Create the needed objects for Scanner, Random, and LocalDateTime/DateTimeFormatter classes Scanner input = new Scanner(System.in); Random random = new Random(); LocalDateTime dateTime = LocalDateTime.now(); DateTimeFormatter frmt = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss"); dateTimeFormat = dateTime.format(frmt); // Starting the game by entering a name ******************************** System.out.println("Enter your name to begin this fast-action game, and let's LOCK N ROLL!"); System.out.println(); System.out.print("Name: "); name = input.next(); name = name.toUpperCase(); System.out.println(); do { // Starts based on playAgain == false System.out.print("How many turns would you like in this game? "); turns = input.nextInt(); System.out.println(); turnHist = new String[turns]; // Start the loop for the number of turns **************************** cntTurns = 0; while (cntTurns 0) pairBonus = 0; strBonus = getStrBonus(roll1); points1 = sum + pairBonus + tripBonus + strBonus; System.out.println(" 1 2 3 Sum Pair Trip Strait Points"); System.out.println(" -- -- -- --- ---- ---- --- ---"); System.out.printf("Roll-1 %d %d %d %d %d %d %d %d ", roll1[0], roll1[1], roll1[2], sum, pairBonus, tripBonus, strBonus, points1); System.out.println(); System.out.println(); // Lock N Roll ************************************************** System.out.println("Now it's time to LOCK N ROLL!"); System.out.println(); for (int i = 0; i 0) pairBonus = 0; strBonus = getStrBonus(roll2); points2 = sum + pairBonus + tripBonus + strBonus; System.out.println(" 1 2 3 Sum Pair Trip Strait Total"); System.out.println(" -- -- -- --- ---- ---- ---- ----"); System.out.printf("Roll-2 %d %d %d %d %d %d %d %d ", roll2[0], roll2[1], roll2[2], sum, pairBonus, tripBonus, strBonus, points2); } else { for (int i = 0; i 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 dio 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 Atumn is an initial roll plus the second roll after lockeroll . 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 Rol 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 o to 3 dice After Lock N Roll, die/dice designated for Roll are rolled for new value (*) 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 Wall die were locked the values from the initial roll are the values for the second roll Turn is completed . ftum completion is not the last tum in the game, a new turn begins starting with the initial roll . If tum completion marks the last tum in the game, system displays the turn history Including initial and final dice values, finalsum, 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 YorN 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.printlno.) . For example Enter your name: Kevin System must accept entered letters, such as LRY N. in either uppercase or lowercase Use the String method, toppercase(), e.g. yesNo = yes No toUpperCase. Dice roll must be sorted for presentation and when choosing Lor R Use Aravsson 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 Rol. Turn and Game (NEW) Sustem should be submitted in one lava file with the river race first followed by chlert races 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 Roland 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. Your Name_Projec12 java Object classes must be organized as follows: (NEW) Variables declared at the beginning of the class Exception is local vars, such as inti 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 gotter methods for these variables Al methods in the object classes have a visibility of public and are not static (NEW) Use arrays for storing of dice values, eg 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.print() 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 subsection) of your code Previous Code to work off: . Package projecti; uport java.sme. LocalDateTine: import java.time.format.DateTimeFormatters Leport java.util.Arrays: import java.util. Randon: import java.util.Scanner public class Projecti_Lockholl { public static void main(String[] args) // TODO Auto-generated method stub Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
