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
In this assignment I would like to have java code that would have either JFrame or something similar with multiple buttons like "BaseCase", "CoalLosses", "Demand", "NoCT,nuclear",

Write a program that uses one of the Map classes to implement a contact list. Contact information should include first name, last name, a phone number and an email address. The lis

How DoS attack is a cyber crime? For what cyber crime can be used? DoS stands for Decline of Service and it is a cyber crime as it jams and within a few cases shut down the goa

Develop Billing Software Project Description: Need software to print bills on A4 paper in the format provided. The details are shown below - 1. Serially generated Invoice

Write a program called BaseConverter that prompts (asks) the user for a base 10 number and another number, between 2 and 10 inclusive. This second number is the base to which to co

1- I need application used android studio with source code and all file . same this application : 2-">https://play.google.com/store/apps/details?id=com.magnetic.openmaps&hl=en 2

Project Description: (1) I want a comprehensive list of Australian chiropractors. The data requires coming from various sources including Google but the following are obligatory

Depicts the typical communication between external users and the system. The emphasis is on what a machine does rather than how it works it. A use case is a summary of scenarios fo

The default nature of an object's clone() function automatically provides a shallow copy. So to need a deep copy the classes have to be edited or adjusted.   Shallow co

Students will design, develop, test and document a Java application that reads data from an input file, processes the data, and then writes the processed data to an output file. CM