Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Lottery.java and FakeLottery.java. First, you will design a class name Lottery w

ID: 3771980 • Letter: L

Question

Lottery.java and FakeLottery.java. First, you will design a class name Lottery which has one private instance variable - an integer array ticket. Complete all the methods of the class Lottery (given below) according to the comments provided inside the methods. Add additional methods if needed. public class Lottery { private int[] ticket; public final int size = 8; public void generateTicket() { /* * this method will generate random number in the range of 0 through 9 (0 and 9 included) for each element in the ticket array */ } public Lottery() { ticket = new int[size]; //call the method generateTicket() to initialize the ticket array } public int[] getTicket() { // return an exact but independent copy of ticket array } public void ToString() { //displays the ticket as an integer } public void setTicket(int[] newTicket) { size = newTicket.length; //copy the contents of newTicket in the instance variable ticket } public boolean MatchTicket(int[] ticketDrawn) { /* * compares the corresponding elements in ticketDrawn and ticket * returns true if all the corresponding elements match */ } } Now design another class called FakeLottery that extends the previous class Lottery. In this derived class, override the method generateTicket() as described by comments inside the method. Add additional methods if needed. public class FakeLottery extends Lottery { public FakeLottery() { super(); } public void generateTicket() { /* * this method will 1. generate random number in the range of 0 through 4 (0 and 4 included) for the first 4 elements in the inherited ticket array 2. generate random number in the range of 0 through 9 (0 and 9 included) for the remaining elements in the inherited ticket array */ } public static void main(String[] args) { // TODO Auto-generated method stub } }

Explanation / Answer

//Main Class:

//Lottery Class:

//FakeLottery Class:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote