Question: Create a class called GiftExchange that simulates drawing a gift at random out of a box. The class is a generic class with a parameter

Create a class called GiftExchange that simulates drawing a gift at random out of a box. The class is a generic class with a parameter of type T that represents a gift and where T can be a type of any class. The class must include the following :

- An ArrayList instance variable that holds all the gifts,The ArrayList is referred to as the box. - A default constructors that creates the box. - An add method that adds a gift to the box. - A drawGift method that Ensure the box is not empty, if it is empty returns null. If not empty Selects a gift at random from the Box. Removes that gift from the Box Returns the selected gift.

No Javadoc or import statements required.

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!