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

image text in transcribed
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 1. An ArrayList instance variable that holds all the gifts, The ArrayList is referred to as theBox. 2. A default constructors that creates the box. 3. An add method that adds a gift to the box. 4. A drawGift method that 1. Ensure the box is not empty, if it is empty returns null. 2. If not empty 1. Selects a gift at random from the Box. 2. Removes that gift from the Box 3. Returns the selected gift. 5. You may add any other method(s) you think you need howwever no additional functionality is required. 6. No Javadoc or import statements required. Doe FB F9 F10 F12 Prtsc oser 7 8 9

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_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions