Answered step by step
Verified Expert Solution
Question
1 Approved Answer
ur task is to create an application for a dog boarding facility. At the end of each day, each dog is assigned a score for
ur task is to create an application for a dog boarding facility. At the end of each day, each dog is assigned a score for its behavior that day. The owners wish to rank dogs based on their behavior and the number of days they have been at the facility. The ranking is based on their behavior score times the number of days they have been there. For example, a dog with a behavior score of who has been boarding for days, would have a total score of To complicate matters, the owners want to score puppies differently. Puppies will have points added to their score behavior score times the number of days they have been there In addition, if a puppy has been boarding for more than days, then its ranking will be based on the behavior score times the number of days times two. For example, a puppy with a score of who had stayed for days would have a total score of x If that puppy stays for days then its total score would be x You must complete an application that will identify the top dog and a list of bad dogs.You have been given the text file containing the dogs and their info in dogs.dat, and the driver class.The driver class Kennel contains two methods that you must implement: public static String getTopDogArrayList dogsReturn a string with the name and score of the dog with the highest score public static String getBadDogsArrayList dogs, int limitReturn a string with the names and score of dogs with scores less than limit one per lineYou must first create an abstract Dog class that contains the name, age, behavior score, and days boarded. This class must contain: Accessors for the name and age, An abstract getTotalScore method that returns the total score, A constructor, An overridden toString method that gives the name and score, and Implementation of the Comparable interface described belowYou will also need two child classes of the abstract Dog class: AdultDog and PuppyDog. The two subclasses of the abstract classes will be concrete; therefore, they must provide a definition for the getTotalScore method.Implementing the Comparable InterfaceThe Comparable interface is really useful. To implement this type of interface you must provide a little more info, specifically you need to tell the interface what type of Object an instance of the Dog class can be compared to In other words, your class header will look like this:public abstract class Dog implements ComparableThe bit in the angled brackets states that Dog objects can be compared with other Dog objects.Your compareTo method must have a header like this:public int compareToDog otherStudentThis method: returns a negative value if the other dogs score is greater than this dogs score returns if the objects are equal, and returns a positive value if the other dogs score is less than this dogs score
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