Question
In this lab, we will use inheritance to create several subclasses that inherit functionality from a superclass. We will also use an array or an
In this lab, we will use inheritance to create several subclasses that inherit functionality from a superclass. We will also use an array or an ArrayList to pass a set of objects of the same type to a method for processing.
This lab will simulate a dog show. We will create several classes representing different species of dogs. Each of these classes will extend the Dog class, provided as an attachment.
Create the following three classes, each of which extends the Dog class. For each class, override the speak() method to return the specified String:
Poodle: speak() must return "yip yip yip"
PitBull: speak() must return "grrr"
Hound: speak() must return "ooooo"
Also, create a static method in the provided DogShow class that evaluates some number of Dogs and chooses one as best in show -- the winning dog of the dog show. The method should be named chooseBestInShow, and it should accept a number of Dogs formatted as an array, an ArrayList, or a variable length argument. Call the provided judgeDog() method to get a score for each Dog; the winner will be the Dog with the highest score. If there is a tie, choose any of the Dogs with the highest score.
Finally, create a main method in DogShow to simulate a dog show. Create the following dogs:
a Poodle named Alex
a PitBull named Blake
a Hound named Carl
Use the chooseBestInShow method to find a winning dog. Print the winning dog's name, and print the output of the dog's speak() method. For example, if Alex the Poodle is the winner, the program should print the following:
Alex wins best in show!
yip yip yip
Upload the Poodle, PitBull, Hound, and updated DogShow source files to Blackboard. For 15 points extra credit, overload three versions of the chooseBestInShow() method: one that accepts an array, one that accepts an ArrayList, and one that accepts a variable length argument.
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