Answered step by step
Verified Expert Solution
Link Copied!

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 5, who has been boarding for 3 days, would have a total score of 15. To complicate matters, the owners want to score puppies differently. Puppies will have 4 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 2 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 3 who had stayed for 2 days would have a total score of 4+2 x 3=10. If that puppy stays for 3 days then its total score would be 4+2(3 x 3)=22. 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: 1) public static String getTopDog(ArrayList dogs) Return a string with the name and score of the dog with the highest score 2) public static String getBadDogs(ArrayList dogs, int limit) Return a string with the names and score of dogs with scores less than limit, one per line You 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 below) You 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 Interface The 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 Comparable The 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 compareTo(Dog otherStudent) This method: returns a negative value if the other dogs score is greater than this dogs score returns 0 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

8. What are the costs of collecting the information?

Answered: 1 week ago

Question

c. What were the reasons for their move? Did they come voluntarily?

Answered: 1 week ago

Question

5. How do economic situations affect intergroup relations?

Answered: 1 week ago