Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 01 Objectives: Familiarity with Eclipse IDE Java syntax, the String class Object oriented programming Task: Just another Zoo! We are looking for a basic

Lab 01 Objectives:

Familiarity with Eclipse IDE

Java syntax, the String class

Object oriented programming

Task: Just another Zoo! We are looking for a basic software to help manage a zoo. Version 1.0 of the software will create Java objects to represent the zoo itself, the zones/areas within the zoo, and the animals in each zone. With this software, zoo operators will be able to plan and track animals in each zone of the zoo as it makes progress and opens. Getting Started Create a new project in Eclipse, following the lab guidelines. Create the following new Java classes, in the default package:

(Use these names exactly!) Zoo.java Zone.java Animal.java Lab1.java

Place the Lab1.java class provided in the same default package within your project. Note that this code will not compile until you have completed the requirements of this lab. There will be syntax errors until all dependencies (classes and methods) are created and implemented. Lab1.java has a main method and will be the class to run our application. Follow the remaining instructions for each class in this lab in order to get your code to compile - do not change the Lab1.java class. Zoo This class will represent a Zoo object, which we will define as having: A name, represented as a String (i.e.: Animal Kingdom Zoo) Zones, stored as an array of Zone objects (i.e. Zone[]) A toString() method, which calls upon the toString() method in Zone.java to return as a String all needed information. An addZone(..) method, which takes as a parameter a Zone object and returns nothing. This class must have a constructor and getters and setters to accommodate its variables. Zone This class will represent a Zone object, which we will define as having: A name, represented as a String (i.e.: Tiger Zone) An array of Animal objects. A toString() method which returns a String representation of all animals in the zone An addAnimal(..) method, which takes as a parameter an Animal object and returns nothing. This class must have a constructor and getters and setters to accommodate its variables. Animal This class will represent an Animal object, which we will define as having: A name, represented as a String (i.e. Tigger) A type, represented as a String (i.e. Tiger) Whether or not the animal is Carnivorous. This will be represented as a boolean (i.e. true, for Tigger) A toString() method which returns a String representation of the animal object This class must have a constructor and getters and setters to accommodate its variables. As this lab is meant to review regular arrays in Java, no other data structure may be used to store the objects required. (No ArrayLists are permitted, for example).

image text in transcribed

The Lab1 Java class needs to match this:

public class Lab1 { public static void main( String[] args ) { Zoo animalKingdom = new Zoo( "Animal Kingdom Zoo", 10 ); Zone m = new Zone( "Monkey", 10 ); Zone t = new Zone( "Tiger", 2 ); Zone l = new Zone( "Lion", 20 ); Zone e = new Zone("Elephant", 15); Animal bubbles = new Animal( "Monkey", "Bubbles the Chimp", false ); Animal grape = new Animal( "Monkey", "Grape Ape", false ); Animal sher = new Animal( "Tiger", "Shere Khan", true ); Animal tigger = new Animal( "Tiger", "Tigger", true ); Animal aslan = new Animal( "Lion", "Aslan", true ); Animal simba = new Animal( "Lion", "Simba", true ); Animal christian = new Animal( "Lion", "Christian", true ); Animal elmar = new Animal( "Elephant", "Elmar", false ); m.addAnimal( bubbles ); m.addAnimal( grape ); t.addAnimal( sher ); t.addAnimal( tigger ); l.addAnimal( aslan ); l.addAnimal( simba ); l.addAnimal( christian ); e.addAnimal(elmar); animalKingdom.addZone( m ); animalKingdom.addZone( t ); animalKingdom.addZone( l ); animalKingdom.addZone( e ); System.out.println(animalKingdom); } }
Output Once your code compiles, you will be able to examine the output of your program. The output of your program must match the format of the sample below. This sample is the result of running the Labl.java class with the given main method. Welcome to the "Animal Kingdom Zoo"! - - - - - - - - - - ---- Monkey Zone : - - - - >> Monkey - Bubbles the Chimp (Vegetarian) >> Monkey - Grape Ape (Vegetarian) Tiger Zone : - - - - - - - - - >> >> Tiger - Shere Khan (Carnivore) Tiger - Tigger (Carnivore) Lion Zone : >> Lion - Aslan (Carnivore) >> Lion - Simba (Carnivore) >> Lion - Christian (Carnivore) Elephant Zone : >> Elephant - Elmar (Vegetarian)

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_2

Step: 3

blur-text-image_3

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

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions