Question: i need code for this peg game, extra credit included (details are in second photo) 2. (20 points) Use a Java Main Class file titled

i need code for this peg game, extra credit included
(details are in second photo)  i need code for this peg game, extra credit included (details
are in second photo) 2. (20 points) Use a Java Main Class

2. (20 points) Use a Java Main Class file titled "PegBoard Gome" In the following problem, pegboard is an AtrayList with numbers. Each number in the list represents a hole that can be pegged. The list can have N number of items where N is a class variable (static final). Assign N to 10 1. (4 points) Define a method (static method) create pegboard that takes no arguments and creates the pegboard with N number of holes (use a for loop and the add method of arrays). This method returns the pegboard created (an arrayList with numbers). 2. (4 points) Define a method (static method) grint.eegboard'AuraylistsInteger pegboard) that takes a pegboard and prints it i.e. prints the items in the Attaulist). This method does not have a return value and hence Is a void method. Your method should work for any values of N > 1. Here's how the pegboard with 10 holes should look when you print it: (1) 2(3) (4) (5) (6) (7) (8) (9) (10) Note: You will need to convert the integers into strings before printing 3. (6 points) Dolne a method (static method) ace hold Axeylist integer pegboard) that takes a pegboard. Based on user choice the method will peg one of the holes with a if it is not already pegged. For example, if user chooses to peg the hole 2, the pegboard with 10 holes should look like: (1) (OLD) (4) (5) (6) (7) (8) (9) (10) If it is already pegged, print an appropriate message. 4. (6 points) in the main method, add the following code to test your methods and add comments to explain each line of the code. Be specific and provide detailed explanation. For example, first line the method createBegboardl) that takes no arguments is called, which creates an array list with N numbers and returns that list. The returned list is assigned to the ArrayList variable pegboard BERL pegboard - SeSats..begkaardo: Brant.reaboard (pegboard) for (int x = 0; 1. 10; 1++) Rehobe (pegboard) print.eegboard (pegboard); Optional Challenge (Extra Credit 10 points): The pegboard can be a fun game. You can generate two random numbers which will simulate two dies. The user has to peg the holes such that the sum of the values of the dies is equal to the sum of the numbers pegged. For example, the dies roll 11 and the user pegs 5 and 6, the dies roll 6, the user pegs 4 and 2, then the dies roll 2 and there are no pegs that can create 2 so roll again and so on. The game continues until all pegs are filled (wint) or it is not possible to fill all pees (losel)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!