Question
--CAN YOU ANSWER IN THE JAVA-- Out-Gen Corporation's Dino Park would like to have a system for tracking and simulating their dinosaurs in the enclosure.
--CAN YOU ANSWER IN THE JAVA--
Out-Gen Corporation's Dino Park would like to have a system for tracking and simulating their dinosaurs in the enclosure. Among other things, these must be counted regularly.
The Enum MapObjectType: This indicates the type of object on the map. "EMPTY", "FENCE", "HERBIVORE", and "CARNIVORE" are possible. More on the different types below.
The class Dino: This class contains the basic functions of a dino. Each dino receives an integer ID, which can be called up via a get function. In addition, a dinosaur should still save the name of its species, which can also be called up via a get function. A dino is represented in an issue as the first letter of its species and its ID. To do this, override the toString() method. This class is not intended to be instantiable. Choose your type accordingly.
The Herbivore class: This class is a subclass of Dino and implements the MapObject class. The print() function should return the dino as a string "H:
The Carnivore class: This class is also a subclass of Dino and implements the MapObject class. The print() function should return the dino as a string "C:
The MapObject interface: This interface serves as a default for other classes that have to implement the functions for a MapObject. A MapObject is the superset of all objects that can be placed on the map. The following functions must be implemented as a minimum:
->getType(): Returns the corresponding MapObjectType
->print(): Returns the string representation of the object
->isEdible(): Returns true for herbivores, otherwise
shad
->canMove(): Returns true for herbivores and carnivores unless this dino has already been moved in the current turn
The Map class: This class manages the map. First create a constructor that takes the size of the square map and the number of carnivores and herbivores and creates both map and dinos (e.g. dino names can be drawn randomly from a created list). The dinosaurs should be placed randomly on the map. 10% of the fields should also be enclosure fences (simply random, no meaningful pattern is required).
To determine whether an object exists at specific coordinates, the class provides the checkCoordinates(x,y) function. This returns a value of the Enum ObjectType depending on the content of the field. The getCoordinates(x,y) function should be used to get the specific object. This also gets an x and y coordinate, but returns the object there (instead of just the type from the enum).
The toString() function must be correctly overwritten and outputs the entire map according to the specifications already made. In addition, a box should be drawn around the map and empty fields filled with spaces to achieve a nice formatting. Fence fields should be marked with an "X". Think of a design to be able to process the 2-3 digit Dino-ID'S well.
The GameMaster class: The GameMaster class manages the gameplay. She creates a 20x20 map with 5 carnivore and 20 herbivore dinos using a 2D array of type MapObject. The gameLoop() function controls the flow of the game. The game is over when all herbivore dinos have been eaten. The days that this lasts should be counted. Choose a suitable loop.
In one day, the following actions must be performed:
->Each field of the array is called. If a carnivore dino was found, a search is made for herbivore dinos in a radius of one field around it. If a herbivore dino is found in this radius, the carnivore dino will try to eat it (see above, whether this is successful depends on chance). If successful, the herbivore dino will be deleted. Radius of 1 also means diagonally:
# # #
#T3#
# # #
->Each dino is moved one square in any direction. To do this, iterate over the map again. When a dino is found, you randomly decide in which direction it will run and change the fields accordingly. Make sure that a dino cannot run off the map or onto an already occupied field.
->Output of the map on the command line.
-> Output of the stock of dinosaurs, i.e. a list of all dinosaurs, or (free choice) the number of dinosaurs of each species that are still alive.
You are free to implement other small classes, e.g. for a fence, to achieve a more elegant object-oriented design.
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