Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

Students also viewed these Databases questions

Question

Address it to art bowers, chief of production.

Answered: 1 week ago

Question

Dr. paul hansen is joining our staff.

Answered: 1 week ago

Question

When jones becomes ceo next month, well need your input asap.

Answered: 1 week ago