Answered step by step
Verified Expert Solution
Question
1 Approved Answer
need help with these last few java classes this is what I have so far THIS IS WHAT IS NEED Park.java : Dinosaur.java : Sauropod.java:
need help with these last few java classes this is what I have so far
THIS IS WHAT IS NEED
Park.java : Dinosaur.java : Sauropod.java: Stegosaur.java : Place the given Lab1.java class in the 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 implemented. main method. Welcome to Jurassic Park! * Theropod: Velociraptor named Blue (carnivore) * Theropod: Velociraptor named Delta (carnivore) * Theropod: Velociraptor named Echo (carnivore) * Theropod: Tyrannosaurus named Rex (carnivore) * Sauropod: Apatosaurus named Littlefoot (not carnivore) * Sauropod: Brachiosaurus named Bob (not carnivore) * Stegosaur: Stegosaurus named Spike (not carnivore) Park.java This class will represent a Park object, which we will define as having: - A name, represented as a String (e.g.: Jurassic Park) - A max capacity of dinosaurs, represented as an int (e.g. in Lab1.java, the max capacity is set to 10) - Dinosaurs, stored as an array of Dinosaur objects (e.g. Dinosaur[]) - A toString() method, which calls upon the toString() method in Dinosaur.java to return as a String all needed information (see the output above). - An addDino(..) method, which takes as a parameter a Dinosaur object and returns nothing. Dinosaur.java This class will represent a Dinosaur, which we will be an interface. This interface should declare the following methods (for the subclasses to implement): - A toString() method which returns a String representation of the dinosaur (see output above) - A method isVegetarian(), which takes no parameters and returns a boolean for whether or not the dinosaur is a vegetarian (if not, they eat meat!) - A getName() which takes no parameters and returns a String of the dinosaur's name (e.g. "Echo") - A getType() method which takes no parameters and returns a String of the dinosaur's type (e.g. "Theropod - Velociraptor") Theropod, Sauropod, \& Stegosaur These classes will be abstract classes, representing the types of dinosaurs in our park. This class should implement the Dinosaur interface and each should have: - A name, represented as a String (i.e.: Rex) - Whether or not the dino is a vegetarian - very important! This will be represented as a boolean (e.g. fa/se, for Rex, our tyrannosaurus) - A constructor which takes in a String name and a boolean for their vegetarian diet and initializes the fields. - A toString() method which returns a String representation of the dinosaur by calling upon "getter" methods. - A getType() method, fulfilling the requirements of the super class. - An abstract method getSubType(), which takes no parameters and returns a sub type of dinosaur (e.g. "Velociraptor"). This method should be called by the getType() method. Theropod, Sauropod, \& Stegosaur These classes will be abstract classes, representing the types of dinosaurs in our park. This class should implement the Dinosaur interface and each should have: - A name, represented as a String (i.e.: Rex) - Whether or not the dino is a vegetarian - very important! This will be represented as a boolean (e.g. false, for Rex, our tyrannosaurus) - A constructor which takes in a String name and a boolean for their vegetarian diet and initializes the fields. - A toString() method which returns a String representation of the dinosaur by calling upon "getter" methods. - A getType() method, fulfiling the requirements of the super class. - An abstract method getSubType(), which takes no parameters and returns a sub type of dinosaur (e.g. "Velociraptor"). This method should be called by the getType() method. Velociraptor, Tyrannosaurus, Apatosaurus, Brachiosaurus, \& Stegosaurus These classes will represent the specific types of dinosaurs which can be added to the park. These should extend their respective abstract class (see "Getting Started" above for which classes should extend which abstract flasses). In addition, they should have: - A constructor which takes in a String name and a boolean for their vegetarian diet and calls the constructor in the super class. - A getType() method which fulfills the requirements of the super class. - Note that these will be very short classes in terms of amount of code. Dease note for all classes: - Each class must have a constructor and getters \& setters to accommodate all of its variables. - All classes must have a toString() method - 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)Step 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