subject

In this assignment, you are asked to implement a sorted list collection, called ThingSortedArrayBag where Thing is a class that represents an object of your choice. Requirements
Implement your Thing class
Start by choosing what sort of list you would like to keep. For example: • To-do list. • Vacation and travel information • Pets • Real estate properties • pretty much any sort of list
You can be creative about your list. It is prohibited to use grocery items, circles, lines, persons, cars, students, bank accounts, points in two-dimensional space, or songs. Please note that you will reuse your Thing class across more than one programming assignment, so try to choose something that interests you. Include the name of your Thing class and its instance variables in your initial plan submission on February, 4th.
Your Thing class must have the following characteristics: • has a meaningful name (not Thing). • has exactly 2 instance variables such that: o one instance variable must be String and this variable will be used as a search key. o one instance variable must be int and this variable will be used to find aggregate information about Things that are stored in the collection class as will be explained later. • All instance variables must be declared as private.
• Implement a constructor for your Thing class that takes two input parameters to initialize the two instance variables. The order of the input parameters must be as follows String, then int. • Implement getters and setters for all the instance variables of your Thing. • Implement toString method that returns a String representation of your Thing class 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 values in both of the instance variables. Note that, the equality of String attributes should be case insensitive. For example, "MATH", "math" and "Math" match each other. In order to compare strings in Java use the String's equalsIgnoreCase method. For example, the following code prints true:
String str1 = "Hello"; String str2 = "hello"; System. out. println(str1.equalsIgnoreCase(str2) );
• Implement the comapreTo method that takes a Thing object as input parameter and returns either 0, -1, or 1 based on whether the input Thing is equal to, larger than, or smaller than the current thing respectively. Note that Things in your collection are to be sorted on the String search key first, then on the int instance variable. For example, if your Thing is a Circle that has color and radius as the String and int instance variables respectively, then: o (red,10) < (Red,20) because: red is equal to Red and 10 < 20. o (Blue, 10) < (red, 30) because Blue < red in alphabetical order ignoring the case.
The Thing class must also implement the Comparable interface. Assume, for example, your Thing is called Circle, then the class header will be as follows:
public class Circle implements Comparable

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 03:00, Emanuelle7843
Which action describes an aspect of technological design?
Answers: 1
image
Computers and Technology, 22.06.2019 10:30, darrengresham999
Choose the best explanation for the following statement communication is symbolic
Answers: 3
image
Computers and Technology, 22.06.2019 23:30, brainbean
Select all that apply. which of the following are proofreading options included in microsoft word? spell check find replace grammar check formatting check
Answers: 1
image
Computers and Technology, 23.06.2019 00:40, QueenKy6050
Consider the following statements: struct nametype{string first; string last; }; struct coursetype{string name; int callnum; int credits; char grade; }; struct studenttype{nametype name; double gpa; coursetype course; }; studenttype student; studenttype classlist[100]; coursetype course; nametype name; mark the following statements as valid or invalid. if a statement is invalid, explain why. a.) student. course. callnum = "csc230"; b.) cin > > student. name; c.) classlist[0] = name; d.) classlist[1].gpa = 3.45; e.) name = classlist[15].name; f.) student. name = name; g.) cout < < classlist[10] < < endl; h.) for (int j = 0; j < 100; j++)classlist[j].name = name; i.) classlist. course. credits = 3; j.) course = studenttype. course;
Answers: 1
You know the right answer?
In this assignment, you are asked to implement a sorted list collection, called ThingSortedArrayBag...

Questions in other subjects:

Konu
Mathematics, 25.08.2019 15:30
Konu
Chemistry, 25.08.2019 15:30