Question: In Person.java on line 2 7 this is not correct: return Objects.equals ( name , person.name ) ; Names can be compared like this: name.equals
In Person.java on line this is not correct:
return Objects.equalsname person.name;
Names can be compared like this:
name.equalspersonname
but you also need to compare heights and weights, which can be compared using
height person.height
and
weight person.weight
You need to cite sources for where ever you're referencing for this code.
Main should still read in the data from file, just as it did the first time this assignment was given without the tree, but this time the data should be put in a tree instead of in OrderedSet or ImperialSet.
The tree looks fine, but the comments are indented weirdly. Fix the indentation and MAKE SURE TO CITE YOUR SOURCES.
Using this code
public class Main
public static void mainString args
SortedTreeSet tree new SortedTreeSet;
Adding sample people
tree.addnew PersonMario;
tree.addnew PersonLuigi;
tree.addnew PersonBowser;
tree.addnew PersonToad;
tree.addnew PersonPeach;
Trying to add duplicates shouldnt be added
tree.addnew PersonMario;
tree.addnew PersonPeach;
Print the tree in sorted order
System.out.printlnSorted Tree Set:";
System.out.printlntree;
AND THIS ONE
public class Person
private String name;
private int height;
private int weight;
public PersonString name, int height, int weight
this.name name;
this.height height;
this.weight weight;
public String getName
return name;
@Override
public String toString
return name height cm weight kg;
@Override
public boolean equalsObject o
if this o return true;
if o null getClass ogetClass return false;
Person person Person o;
return Objects.equalsname person.name;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
