Question 1 1 pts Something that can be compared to other Comparable things publi
ID: 3746758 • Letter: Q
Question
Question 1 1 pts Something that can be compared to other Comparable things public interface Comparable f * Compare this object with the other object * returns -1 if this comes before other 0 if this and other are the same 1 if this comes after other 8/ public int compareTo (Comparable other); public class Cat implements Comparable f private String breed; private double cutenessRating; public Cat (String breed, double cutenessRating) this.breed breed: this.cutenessRating cutenessRating; @Override public int compareTo(Comparable other) t Cat a(Cat) other; if (this, cutenessRating a.cutenessRating) return -1; else if (this.cutenessRating a.cutenessRating) return 1; else return 0 @Override public String tostring() f return "Cat""breed-" + breed ", cutenessRating-" cutenessRatingExplanation / Answer
Cat{breed=GrumpyCat, cutenessRating=1.0}
Cat{breed=Siamese, cutenessRating=5.8}
Cat{breed=Tabby, cutenessRating=6.0}
if you need more proof of the program running let me know , if you like my answer please appreciate with thumbs up , thanks :)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.