Question: java, do not change Animal.java, create dog.java animal.java: 2. Dog Class: The Dog class should inherit the methods and instance variables defined in the Animal

java, do not change Animal.java, create dog.java
 java, do not change Animal.java, create dog.java animal.java: 2. Dog Class:
animal.java:
The Dog class should inherit the methods and instance variables defined in

2. Dog Class: The Dog class should inherit the methods and instance variables defined in the Animal class, but do not duplicate code. The Dog class has a natural ordering but it CAN delegate to Animal's natural ordering Consider how that changes your implementation). All dogs also have a variable specifying whether or not they have a curlyTail (true or false) and a whole number representing the droolRate. The dog class should have two constructors. One constructor should allow the client to set the name, price, curly tail, and drool rate. The second constructor should allow the client to set only the curly tail and drool rate. For the second constructor, set the default values for price and name to be 50.0 and "none" respectively. All dogs should have a store id of 100. Again, be sure any constructors for this class have parameters in the same order as the variables listed above. Write getters and setters for all of the instance variables. These methods should be named get Variable Name and set VariableName, but replacing VariableName with the actual name of the instance variable. 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. You should define a toString method that returns the toString defined in the Animal class and additionally the dog's drool rate. You should be reusing code here! Look at the examples section, your toString must follow the same formatting. The format should be "Store ID: , Name: , Curly Tail: , Drool Rate: t private int storeId; private String name; private double price; public Animal(int storeld, String name, double price) this.storeld storeld this.name name this.price = price; public Animal(int storeId) this.storeid = store1d; this.name "Buzz" this.price 222.08 public int getStoreld) return storeld public void setstoreldlint storeld) this.storeld storeld; public String getName) ( return name e public void setName(String name)t this.nane nane 3 4 public double getPrice) 35 36 37 38 public void setPrice(double price) t 39 return price this.price prices 41 42 COverride 43 public int compareTo(Animal o) 45 46 47 48 49 50 51 if(storeldo.storeld) return 1 else t return name.compareTo(o.name)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!