X1177: LotteryTicket constructor

Below is a class that represents the numbers picked on a lottery ticket.

public class LotteryTicket
{
    private int[] numbers;

    // your constructor will be INSERTED HERE
}

Below, write a constructor for this class (the constructor only, not the complete class declaration; your constructor will be inserted into the class above). The constructor should take two integer parameters: the first representing how many numbers are on the ticket, and the second representing a player's preferred "lucky number". The constructor should initialize the field with a new array of the correct size to hold all the numbers, and then should set every location in the array to the player's lucky number.

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.