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

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 = new 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 details

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!