Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 1: Animal (10 points) (Software Design) Create an abstract class that represents an Animal and contains abstract methods: move, call. Create concrete classes:
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"
Step by Step Solution
★★★★★
3.48 Rating (148 Votes )
There are 3 Steps involved in it
Step: 1
Animaljava public abstract class Animal Declaring instance variables private String type Parameteriz...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