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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started