Create a generic class with a type parameter, JAVA Programming

1. The purpose of this problem is to practice using generics. 

  • Create a generic class with a type parameter that simulates drawing an item at random out of a box. For example the box might contain Strings representing names written on a slip of paper, or the box might contain Integers representing a random drawing for a lottery. Include the following methods in your generic class, along with any other methods you'd like:
    1. an add( ) method that allows the user to add an object of the specified type
    2. an isEmpty( ) method to determine if the box is empty
    3. adrawItem( ) method that randomly selects an object from the box and returns it. Return null if the box is empty
  • In the driver file that tests your class create 2 boxes, one with the names of 7 friends, the other with numbers between 1 and 5 representing the amount of hours of home work you will do before going to the party you've been invited to. Use the add( ) methods to populate the 2 boxes, and the drawItem( ) methods for each box to determine

i) how many hours of home work you will do before

ii) going to the party with the friend you will invite (from the "friends" box)

Posted Date: 3/21/2013 2:15:35 AM | Location : United States







Related Discussions:- Create a generic class with a type parameter, Assignment Help, Ask Question on Create a generic class with a type parameter, Get Answer, Expert's Help, Create a generic class with a type parameter Discussions

Write discussion on Create a generic class with a type parameter
Your posts are moderated
Related Questions
The software or script to scan automotive ads Project Description: Looking for a company that made the script or application to search through pages of listings of automotive

The fancy new French restaurant La Food is very popular for its authentic cuisine and high prices. This restaurant does not take reservations. To help improve the efficiency of the

Determine the phase Loading- Java Program Development In phase 3, the program must first be placed in memory before it can be executed. This is done by the class loader, whic

Rational Unified Process (RUP) is a normal framework that may be used to define a development process. The software development life cycle has got 4 parts in the following o

Operator Functionality E x ample/Explanation = Sets one value equal to another counter=0  Sets the counter to equivale

A pointcut is something that describes at what joinpoints an advice should be applied. Advices can be applied at any joinpoint that is supported by the AOP framework. These Pointcu

Find representative skyline points in to two dimensional data Project Description: Run skyline algorithm run representative skyline algorithm up to skyline algorithm (Affi

How to draw Polygons in java? In Java rectangles are defined through the position of their upper left hand corner, their height, and their width. Therefore it is implicitly sup

Sequence diagrams are communication diagrams which detail what messages are sent and when. The sequence diagrams are placed according to time. The time performs as you move from to

Explain the difference between pre-emptive scheduling and time slicing ?