Answered step by step
Verified Expert Solution
Question
1 Approved Answer
DO NOT COPY FROM OTHER CHEGG ANSWERS. create the compareTo method ONLY for dog. java: animal.java: animal compare to rules: srry , dog class: Dogs
DO NOT COPY FROM OTHER CHEGG ANSWERS. create the compareTo method ONLY for dog. java:
animal.java:
animal compare to rules:
srry , dog class:
Dogs have a natural ordering similar to that of the Animal class. Override a method in the Dog class that compares two dogs. If the Animal class determines that two dogs are equal, then sort the dogs by the descending order of drool rate. In other words, be sure you are reusing code from the parent class when possible. If the animal passed into this method is not a Dog refer to the parent's compare method. Proect Window Help Dog-java l public abstract class Animal impements ComparablecAnimal> private int storeld; private String nane; private double price: blic Aninal(int storeid, String name, double price) this.storeld storeld: this.nane nane; this.price price public Animal(int storeld) this.storeid = storeld; this.name Buzz" this price 222.80; 18 public 8 public int getstoreld) t return storeld: 22 public void setStoreld(int storeId) t this.storeld storeid 26 public String getName) 28 return nane; public void setName (String name) 31 this.name name; public double getPrice) return prices 37 public void setPrice double price) this.price price: 40 41 COverride public int compareTo(Aninal anial) ( if (storeld 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