Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 1 : Make a box that can hold one item This first part checks that you know how to use generics, write JavaDocs, and
Part : Make a box that can hold one item
This first part checks that you know how to use generics, write JavaDocs, and use the basic command line tools youll use
throughout the semester. You need to write a generic class called SingleItemBox in a file called
SingleItemBox.java that you create It must have the following three features:
a constructor that takes a single item and puts it in the box.
a method called getItem which provides the item back to the user but does not remove it from the box this is
an accessor if you remember, sometimes called a getter
a singleparameter method called setItem which puts a new item into the box and returns the old item.
NOTES:
Make sure to comment your code as you go in proper JavaDoc style.
Item put in the box cannot be null you must check this and throw an IllegalArgumentException with error
message "Item cannot be null!" if null is used.
DimitriadisZhong Project : Project Skills Check CS Spring
To check that youve got the right idea, weve provided a class called BoxUsageDemo.java which creates boxes for
items of different classes. You should not alter this class to make it work but rather alter your box to allow the provided
code to work and print our yays You can use the command "java BoxUsageDemo" to run the testing code defined in
main You could also edit this main to perform additional testing we wont be using BoxUsageDemo for testing,
its just a demo for you
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started