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
Question : a) There are up to 14 different built-in groups that might be located by default in the Builtin container including "Account Operators", "Incoming Forest Trust Bui

What is Alternate Text ? The APPLET element can have an ALT attribute. An ALT attribute is used through a browser which understands the APPLET tag but for some purpose cannot

Need a new E- payment gateway Project Description: I need a new payment gateway of my own. Anyone who has previous experience in preparing a new payment gateway. I mean new p

Messaging is a method of communication among software components or applications. A messaging system is a peer-to-peer facility: A messaging client can send messages to, and receiv

Project Description: We are looking to prepare an app which allows the user (a student or an expat in a new country) to select from a list of furniture items to prepare a packag


Project Description: I need a new payment gateway of my own. I mean new payment gateway not any integration. So please bid only if you had made a payment gateway former like

Object diagrams define instances instead of classes. They are useful for illustrating some complicated objects in detail about their recursive relationships.     When

Question 1 What is Response Redirection? Explain in brief Question 2 What is JDBC? Explain Question 3 Write a short note on Expressions Question 4 What is an XML na

iiiiii