Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Programming Assignment: Thing Class Goal: To represent an object in Java Problem Description You will be writing programs to manage collections of things where you
Programming Assignment: Thing Class
Goal: To represent an object in Java
Problem Description
You will be writing programs to manage collections of "things" where you get to choose the "thing" in the collection. Since you will be reusing your Thing class across more than one program, please choose something that interests you.
Thing Class
Create a Thing class. The Thing class will be Movie. Your Thing class must have the following characteristics:
Include at least private instance variables fields such that:
o the first instance variable must be of type String and this variable will be used as a search key
the second instance variable must be integer ie int and this variable will be used to find aggregate information about Things that are stored in a collection class as will be explained later
the third variable must be of type boolean
Implement a threearguments constructor for your Thing class. The arguments must be in the order String int, boolean
Implement getters and setters for all the attributes of your Thing.
Implement a toString method that returns a String representation of your Thing where all the instance variables are in one line and separated by tabs
Implement the equals method for your Thing where two Things are considered equal when they have the same search key. Note that, the equality of String attributes should be case insensitive. For example, MATHmath and Math match each other. In order to compare strings in Java use the String's equalsIgnoreCase method. For example, the following code should print true:
String str "Hello";
String str "hello";
System.out.printlnstrequalsIgnoreCasestr;
Implement the compareTo method for your Thing. compareTo returns
a negative number when the invoking object's search key is less than the parameter's search key
when the two search keys are equal
a positive number when the invoking object's search key is greater than the parameter's search key
For example, "ant".compareTobat will return a negative number. Your compareTo method must compare two Things. Note that the comparison of String attributes should be case insensitive. For example, MATHmath and Math must match each other.
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