Problem 1: Animal (10 points) (Software Design) Create an abstract class that represents an Animal and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Problem 1: Animal (10 points) (Software Design) Create an abstract class that represents an Animal and contains abstract methods: move, call. Create concrete classes: Fish, Bird, Dog which extend the Animal class and implements those methods. A fish swims and calls "glub glub", a bird flies and calls "chirp chirp", and a dog runs and calls "roof roof." Software Architecture: The Animal class is the abstract super class and must be instantiated by one of its concrete subclasses: Dog, Frog, or Fish, which extends from Animal. + type: String Dog Constructor Animal (String type) UML Object Diagram constructor (type: String) getType(): Stri abstract void abstract String call() Animal UML Class Diagram: Bird move() call(): String italicized class/method names within UML Class Dagan indicate abstract classmethods Modifier and Type Method and Description void Animal move() moves this animal Animal Constructor Summary: Description Creates a Animal instance with a given type Animal Method API: getType() Returns the type of this animal Fish Returns as text representation the sound that this animal makes Constructor Dog() +move() + call(): String talicized class/method names within UML Class Diagram indicate abstract classmethods String constructor () UML Class Diagram: Dog Constructor Bird() Dog Constructor Summary: Description Modifier and Type Method and Description void move() Displays to console message: this animal's type + "runs" String Dog Method API: Creates a Dog instance with "Dog" type call() Returns as text "roof roof + constructor () + move() + call(): String "italicized class/method names within UML Class Diagram indicate abstract classmethods UML Class Diagram: Bird Bird Constructor Summary: Description Creates a Bird instance with "Bird" type Bird Method API: Modifier and Type Method and Description void move() Displays to console message: this animal's type fies" call() Returns as text "chirp chirp" + constructor () + move() + call(): String Italicized class/method names within UML Class Diagram indicate abstract class/methods Constructor Fish() String UML Class Diagram: Fish Fish Constructor Summary: Description Modifier and Type Method and Description void move() Displays to console message: this animal's type + " swims" Sample Method Calls Animal[] zoo (new Dog(), new Fish(), new Bird() }; call () Returns as text "glub glub" Fish Method API: Tester Files: Use the TestAnimal.java file to test your implementation. Compare your results with the TestAnimal.txt file. Creates a Fish instance with "Fish" type for (Animal animal zoo) { animal.move(); System.out.println( animal.call() ); Sample Method Results "Dog runs" "roof roof" "Fish swims" "glub glub" "Bird flies" "chirp chirp" Problem 1: Animal (10 points) (Software Design) Create an abstract class that represents an Animal and contains abstract methods: move, call. Create concrete classes: Fish, Bird, Dog which extend the Animal class and implements those methods. A fish swims and calls "glub glub", a bird flies and calls "chirp chirp", and a dog runs and calls "roof roof." Software Architecture: The Animal class is the abstract super class and must be instantiated by one of its concrete subclasses: Dog, Frog, or Fish, which extends from Animal. + type: String Dog Constructor Animal (String type) UML Object Diagram constructor (type: String) getType(): Stri abstract void abstract String call() Animal UML Class Diagram: Bird move() call(): String italicized class/method names within UML Class Dagan indicate abstract classmethods Modifier and Type Method and Description void Animal move() moves this animal Animal Constructor Summary: Description Creates a Animal instance with a given type Animal Method API: getType() Returns the type of this animal Fish Returns as text representation the sound that this animal makes Constructor Dog() +move() + call(): String talicized class/method names within UML Class Diagram indicate abstract classmethods String constructor () UML Class Diagram: Dog Constructor Bird() Dog Constructor Summary: Description Modifier and Type Method and Description void move() Displays to console message: this animal's type + "runs" String Dog Method API: Creates a Dog instance with "Dog" type call() Returns as text "roof roof + constructor () + move() + call(): String "italicized class/method names within UML Class Diagram indicate abstract classmethods UML Class Diagram: Bird Bird Constructor Summary: Description Creates a Bird instance with "Bird" type Bird Method API: Modifier and Type Method and Description void move() Displays to console message: this animal's type fies" call() Returns as text "chirp chirp" + constructor () + move() + call(): String Italicized class/method names within UML Class Diagram indicate abstract class/methods Constructor Fish() String UML Class Diagram: Fish Fish Constructor Summary: Description Modifier and Type Method and Description void move() Displays to console message: this animal's type + " swims" Sample Method Calls Animal[] zoo (new Dog(), new Fish(), new Bird() }; call () Returns as text "glub glub" Fish Method API: Tester Files: Use the TestAnimal.java file to test your implementation. Compare your results with the TestAnimal.txt file. Creates a Fish instance with "Fish" type for (Animal animal zoo) { animal.move(); System.out.println( animal.call() ); Sample Method Results "Dog runs" "roof roof" "Fish swims" "glub glub" "Bird flies" "chirp chirp"
Expert Answer:
Answer rating: 100% (QA)
Animaljava public abstract class Animal Declaring instance variables private String type Parameteriz... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Create an abstract class AbstractClass with an abstract method printMessage. Create two subclasses each implementing the method printMessage that prints "This is first subclass "and " This is second...
-
Create an abstract class called Student from which Freshman and Transfer will inherit. Create the Freshman and Transfer Classes defining only the specific properties that are not defined in your...
-
Create an abstract class PayCalculator that has an attribute payRate given in dollars per hour. The class should also have a method computePay(hours) that returns the pay for a given amount of time.
-
(a) Show that (x) = 2x + 3x 36x is not one-to-one on (-, ). (b) Determine the greatest value c such that is one-to-one on (-c, c).
-
Athens Holding Company operates numerous businesses, including motel, auto rental, and real estate companies. The year 2016 was interesting for Athens, which reported the following on its income...
-
Suppose the liquidity preference function is given by L(I,Y) = Y/8 - 1,000i Use the money demand equation, along with the following table of values, to calculate the velocity for each period. Period2...
-
Xie Company identified the following activities, costs, and activity drivers for 2017. The company manufactures two types of go-karts: deluxe and basic. Required 1. Compute a single plantwide...
-
The following selected transactions were completed during June between Salinas Company and Brokaw Company: June 2. Salinas Company sold merchandise on account to Brokaw Company, $20,000, terms FOB...
-
Suppose your starting salary is $50,000. You would like to open a savings account to save for your retirement and any large future expenses. Most Economists agree that you should allocate 20% of your...
-
On June 1, Cindy Godfrey started Divine Designs Co., a company that provides craft opportunities, by investing $12,000 cash in the business. Following are the assets and liabilities of the company at...
-
5. You have made 10 measurements of the length of a nail using a ruler as shown in the table. You think that you might have made one or more bad measurements. Apply Chauvenet's criterion to eliminate...
-
Yem Company manufactures luggage sets. Yem sells its luggage sets to department stores. Yem expects to sell 2,050 luggage sets for $320 each in January and 2,200 luggage sets for $320 each in...
-
Mark owns a machine shop. In reviewing the shops utility bills for the past 12 months, he found that the highest bill of $2,400 occurred in August when the machines worked 1,000 machine hours. The...
-
Refer to the Packers schedule of cash receipts from customers that you prepared in Short Exercise S22A-17. Now assume that Packerss sales are collected as follows: 50% in the month of the sale 20% in...
-
What is the purpose of variable overhead cost variance?
-
What does profitability mean with regard to performance evaluation in investment centers?
-
Consider two companies, X and Y The business of Company X is sensitive to the economy/market and the business of Company Y is NOT sensitive to the economy/market. Other things being equal, Company...
-
1. Advertising for eyeglasses _________ (increases/decreases) the price of eyeglasses because advertising promotes _________. 2. An advertisement that succeeds in getting consumers to try the product...
-
Create a class named Apartment that holds an apartment number, number of bedrooms, number of baths, and rent amount. Create a constructor that accepts values for each data field. Also create a get...
-
Create a class named Person that holds the following fields: two String objects for the persons first and last name and a LocalDate object for the persons birthdate. Create a class named Couple that...
-
The Huntington Boys and Girls Club is conducting a fundraiser by selling chili dinners to go. The price is $7 for an adult meal and $4 for a childs meal. Write a program that accepts the number of...
-
What is an injunction?
-
What is the main effect of increased use of liability insurance?
-
What are the arguments in favour of imposing a wide liability on professionals?
Study smarter with the SolutionInn App