Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Java 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 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, 2. If not empty # it is empty returns null 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 however no additionalnctionality is required. 6. 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

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions