Question
Java Problem. Here is the test for this I'm stuck trying to find out what to do with the toString() import java.util.ArrayList; public class AnimalTester
Java Problem. Here is the test for this I'm stuck trying to find out what to do with the toString()
import java.util.ArrayList;
public class AnimalTester { public static void main(String[] args){ ArrayList
animals.add(new Dog(70, Animal.AnimalMovement.WALK, Animal.AnimalClass.MAMMAL, "Husky")); animals.add(new Snake(20, Animal.AnimalMovement.SWIM, Animal.AnimalClass.REPTILE, "Sea Snake", false)); animals.add(new Dog(50, Animal.AnimalMovement.WALK, Animal.AnimalClass.MAMMAL,"Poodle")); animals.add(new Snake(68, Animal.AnimalMovement.CRAWL, Animal.AnimalClass.REPTILE, "King Cobra", true)); animals.add(new Snake(15, Animal.AnimalMovement.CRAWL, Animal.AnimalClass.REPTILE, "Garden Snake", false));
System.out.println(animals); } }
Create an Abstract class called Animal as follow: Create two public enum types inside the Animal class: 1. Animal Movement{ WALK, SWIM, CRAWL, FLY} 2. Animal Class {MAMMAL, REPTILE, BIRD, INSECT} Animal class has three instance variables: a. Weight which is of type double b. movement which is of type Animal Movement C. class which is of type Animal Class Animal weight: double movement: Animal Movement animalClass: AnimalClass Animal(double weight, AnimalMovement movement, AnimalClass class) getWeight() how TheyMovel) getAnimalClass() toString() A Snake Dog breed: String snakeType: String poisonous: boolean Snake (double weight, AnimalMovement movement, AnimalClass class, String snakeType, Boolean poisonous) getSnakeType() isPoisonous() toString Dog(double weight, Animal Movement movement, AnimalClass class, String breed) getBreed() toString() Create two concrete classes Snake and Dog. Refer to the above UML diagram for detailsStep 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