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
Object Relational Mapping , its a tool for transaction management that requires to be integrated with Spring, Struts etc.Eg : Hibernate, i Batis,JDO etc

In RPC the method invoker waits for the method to finish implementation and return the control back to the invoker. Therefore it is completely synchronous in nature. Whereas in JMS

what is methods override?

Implement relationship using a java program. Assume each course has a course title, code, subject and number of credits while each student has a name, registration number, list of

could you please help me with my assignment. My program need to implement a multi{level role based database script SQL-like generation program. Or part of one anyway. Start with a

Project Description: I am planning to prepare a website which caters the services to online internet users. I have already prepared most HTML5 pages by own and wanted to impl

How can I improve the performance of a java application , describe the java optimization techniques?

JSP simply gives a Page which may contain markup, embedded Java code, and tags which encapsulate more complicated logic / html. JSF may use JSP as its template, but gives much more

Write a program called Power that displays the positive powers of 2. When the user enters the exponent at a prompt, the program displays 2 to that power. The program halts when the