Answered step by step
Verified Expert Solution
Link Copied!

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 1: 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:
1. a constructor that takes a single item and puts it in the box.
2. 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).
3. a single-parameter 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.
Dimitriadis/Zhong Project 0: Project Skills Check CS310- Spring 2024
3
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

List all the correct attributes of the square root parent function

Answered: 1 week ago