Question: In this increment, you will develop a single wicket cricket game program based on Cricket, and Simulate class. Create another class called Cricket Demg in


In this increment, you will develop a single wicket cricket game program based on Cricket, and Simulate class. Create another class called Cricket Demg in which main method is defined that includes the following code: import java.util. *; public class CricketDemo public static void main(String[] args) { Cricket the Cricket = new Cricket(); theCricket playGame(); } o Create Cricket class as shown in the UML figure 1. The Cricket class contains six attributes, one random instance and mxCricket string array. The Cricket class also contains three methods, one is constructor called Cricket (), other is playCricket() method, and last one is gameOver() method. Constructor Cricket (): The purpose of constructor method is to populate the String variable called myCricket. Assign the string values to array which are as follows: Single, double, three, Four, Six, Catch Out, Wide, No Ball, Bye, Leg Bye, Wicket Out, LBW Out, Stump Out. Moreover, Simulate class is instantiated and object variable of the Simulate class is created. playCricket() method: the purpose of the playcricket() method is to invoke simulateValues() method inside Simulate class. The object of the Simulate class is used to invoke simulateValues() method in Simulate class that generates random number to be returned to the calling method. The simulateValues() method generates a random number and return it to the calling environment of playCricket() method in Cricket class. This random Number value is used as an index number to get value from already populated string in the constructor. You may also use playerScore to increment the number with single, double, four...etc. Simulate class: In this increment, we are going to add a new class called Simulate Class that contains two variables. One is randomValue variable and other is to use Random instance called randomNumber that is used to generate random numbers from 0 to 12. Constructor Simulatel) method is used to instantiate Random by creating object variable called randomNumber, Random randomNumber = new Random(); Cricket Simulate Cricket Demo the Cricket + main(String[]); void theSimulator + playerScore: int + batsmanName: String + bowler Name: String + balls: int + overs: int + simulateValue: int + myCricket: String[] + Cricket + playCricket(): vold gameOver(); void + randomValue: int + randomNumber: Random Simulatel + simulateValueso) Figure 1: Increment 3 UML Class Diagram Increment 3-Output C:\Users\janna\Desktop\Programming in JavaSource code Assignment-4>javac CricketDemo.java C:\Users\janna\Desktop\Programming in Java\Source code Assignment-4>java CricketDemo Please enter the name of the batsman: Ricky Ponting Please enter the name of the bowler: Shoaib Akhthar Shoaib Akhthar take a start and bowled 1 ball Appeal for LBW LBW Out The score is o Ricky Ponting's score was Same is over. Stay tuned and see you next time C:\Users\janna\Desktop\Programming in Java\Source code Assignment-4>java CricketDemo Please enter the name of the batsman: Sunil Gavaskar Please enter the name of the bowler: Imran Khan Imran Khan take a start and bowled 1 ball What a Yorker Wicket Out The score is o Sunil Gavaskar's score was O Game is over. Stay tuned and see you next time
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
