Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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: animal.java:
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