Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions