Create a generic class with a type parameter, JAVA Programming

Assignment Help:

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)


Related Discussions:- Create a generic class with a type parameter

Applying java if and if..else statements, For this Assignment, submit the f...

For this Assignment, submit the following program: Create an application for an animal-fur trimming service. The business is open 15 weeks of the year, from April through July. The

Functionality of customer relationship management system, The basic system ...

The basic system has to offer the following options: 1. Exit the program 2. Enter new customer The program prompts for the details of a new customer, assigns a unique cust

Write a program on clearing rectangles, Write a program on clearing Rectang...

Write a program on clearing Rectangles ? It is also potential to clear a rectangle that you've drawn. The syntax is exactly what you'd expect: public abstract void clearRect

Explain jar archives, Explain JAR Archives ? HTTP 1.0 uses a separate ...

Explain JAR Archives ? HTTP 1.0 uses a separate connection for every request. When you're downloading several small files, the time required to set up and tear down the connec

Write a java applet using swing components, The project is optional. It is ...

The project is optional. It is worth at least 7 bonus points beyond overall 100 points of this course. The grading will be on a pass/fail basis. Write a Java application (not ap

Nested For-Loop, I''m having trouble with creating a nested for loop to cre...

I''m having trouble with creating a nested for loop to create a table that displays every number divisible by two within the given value. For example, if the number is 8 then there

What are the role of keywords in java, What are the role of Keywords in jav...

What are the role of Keywords in java? Keywords are identifiers such as public, static and class in which have a special meaning inside Java source code and outside of comments

Define the n-tier architecture or j2ee 3-tier?, Normal 0 false ...

Normal 0 false false false EN-US X-NONE X-NONE

Want inventory selection function in opentaps erp, Required: Inventory Sele...

Required: Inventory Selection Function in Opentaps ERP We work on Opentaps ERP and Application development framework. Our requirement is to modify the Inventory selection functi

Exercise\servletexercise, Ask question # Write a servlet to display a table...

Ask question # Write a servlet to display a table that contains factorials for the numbers from 0 to 10,

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd