Problem Description
Nintendo’s human resources data is all out of order, full of duplicates, and in metric! The information is stored in a database file, hr.txt and it’s your task to create two new versions of it.
List of classes that you will write:
Your task is the following:
Various Important Notes:
Neither PersonOrderedSet nor PersonImperialSet should contain duplicate date, but the code that takes care of such things should be implemented in the add method of PersonSet.
You must use super.add(c) as the final step in PersonImperialSet.add after the conversion has been completed. (Assuming that c is a variable referring to a Person object to be added to the set.)
You are strongly encouraged to use super.add(c) in PersonOrderedSet.add and then perform a sort of the data to make sure everything is in order. (Assuming that c is a variable referring to a Person object to be added to the set.)
You need to open the database file, hr.txt, and read in the information in Main.
Objects are passed by reference, not by value. If you add the same Person to PersonOrderedSet and PersonImperialSet you will see that the units get changed from metric to imperial in both. This is NOT what you want. One solution to this problem is to instantiate two new Person objects and pass the same name, height, weight info to each, and then pass one to the imperial set and the other to the ordered set. Another solution is to overload the Person constructor so that you can pass a Person type variable to the constructor and the constructor will take care of copying the data. This solution will still require two separate instantiations of Person in main.
If you want to use the ArrayList contains method to see if a Person is already in the set, then you need to make sure that Person overrides the default equals method. To do so, fill in the following comment outline and also refer to this resource for more information:
https://www.geeksforgeeks.org/overriding-equals-method-in-java/
//Equals method outline
@Override
public boolean equals(Object o)
{
//if Object o is null then return false
//if Object o == this then return true
//if Object o is not an instance of Person then return false
//Declare a new variable of type Person (perhaps named p)
// and assign it to Object o cast as type Person
//if Person p has the same name, height, and weight as
// this then return true
//else return false
}
I will test your program as follows:
javac Main.java
java Main
========================================================================================
hr.txt
Name Height (cm) Weight (kg)
Mario 155 90
Luigi 158 83
Bowser 310 726
Toad 41 7
Mario 155 90
Peach 183 60
Toad 41 7
Bowser 310 726
Bowser 310 726
Toad 41 7
Mario 155 90
Peach 183 60
Peach 183 60
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more