Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Introduction
This assignment tests your understanding of inheritance and polymorphism in Java.
This assignment consists of two parts. You need to implement the basic requirements of the program in part (a). In part(b), you have to extend the program by submitting additional files. Files submitted in part (b) must work with the files in part (a) submitted on or before 28 Feb 2019. You are not allowed to modify the class hierarchy that you have defined and implemented in part (a).
In this assignment, you are required to simulate the wild life in a forest. Program design will be evaluated in this assignment. You must make good use of inheritance and polymorphism to get all marks for this assignment.
You are also required to write JavaDoc for all non-private classes and non-private class members. Programs without JavaDoc will not be marked.
Task
You need to implement the main program, Forest.java, which simulate a forest. A forest is represented by a 2D array of cells. Each cell can be used to hold one animal (an object of a sub-class of Animal class).
Similar to the Animal class hierarchy in the lecture, you are required to implement a hierarchy of animals, as shown below:
When the program starts (i.e., the main() method inside Forest.java), it will create a forest of size 15x15.
Once the forest is generated, print the layout of the forest as follow:
The program then displays the following menu:
1.Dog (d)
2.Fox (f)
3.Wolf (w)
4.Cat (c)
5.Lion (l)
6.Tiger (t)
7.Hippo (h)
8.Turtle (u)
What would you like to add to the Forest?
Please enter your choice (1-8, or 0 to finish the animal input):
When the user enters option 1-8, the program will generate a random location for the animal and show the animal’s moving behavior. The moving behavior of each element will be defined later. E.g. if the user enters 1, the program will show the following:
Added Dog at (2,0): Dog is Canine, Canine moves in four directions, one or two steps a time.
The process should be repeated until the user enters 0 to finish the input. The user may choose to add the same kind of animal again. Please make sure no two animals on the same location.
Ask for input again if the user enters any other input. You can assume that the user will always input an integral value. Your program does not need to handle non-integer input.
A dot indicates an empty space, and a letter indicate an animal at that location. The first letter of each of the 8 animals is used to label them except Turtle is labeled with a ‘u’.