Use the Lottery class to the left as the superclass. Create the PowerBall class as a subclass of Lottery. Override the shuffle method so that it returns an ArrayList of six random integers up to but not including 100.
CODE:
import java.util.ArrayList;import java.util.Random;
class Lottery { public ArrayList shuffle() { Random r = new Random(); ArrayList nums = new ArrayList(); for (int i = 0; i < 5; i++) { int num = r.nextInt(20); nums.add(num); } return nums; }}
//add class definitions below this line
class PowerBall extends Lottery { public ArrayList shuffle() { Random r = new Random(); ArrayList nums = new ArrayList(); for (int i = 0; i < 6; i++) { int num = r.nextInt(100); nums.add(num); } return nums; }}
//add class definitions above this line
public class Exercise1 { public static void main(String[] args) { //add code below this line
PowerBall p = new PowerBall(); System.out.println(p.shuffle()); //add code above this line }}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here