Specification
- Create Animal.java class which has the following attributes
- String species
- int attack
- int health
- Create constructor and getter and setter
- Create a method “fight” with 2 parameters: Animal, String location
- this method will take animal.getAttack() subtract this animal health.
- Create Bull.java class
- This class should inherit from the Animal class.
- The constructor should have no parameter. The constructor should call the parent constructor (super) with the following parameters:
- species: “Bull”
- attack: 6
- health:120
- Create Crocodile.java class
- This class should inherit from the Animal class.
- The constructor should have no parameter. The constructor should call the parent constructor (super) with the following parameters:
- species: “Crocodile”
- attack: 8
- health:100
- Create Lion.java class
- This class should inherit from the Animal class.
- The constructor should have no parameter. The constructor should call the parent constructor (super) with the following parameters:
- species: “Lion”
- attack: 10
- health:90
- Create AnimalFightSystem.java class
- It will have a list of Animal.
- This class will have a run method
- You will create one Crocodile, one Bull, and one Lion objects or variables. Add all of them into the list of Animal.
- This will allow the user to choose 2 animals to fight.
- The program will list all the animals inside the List for user to choose from.
- After 2 animals are chosen, the program will randomly choose either “land” or “water” location for their fighting location.
- After this, both animals will attack each other by calling each other fight method
Expected Outcome
CHOOSE 2 ANIMALS TO FIGHT:
Choose your 1st animal:
0. Crocodile - Attack 8 - Health 100
1. Bull - Attack 6 - Health 120
2. Lion - Attack 10 - Health 90
Enter your selection: 0
Choose your 2nd animal:
0. Crocodile - Attack 8 - Health 100
1. Bull - Attack 6 - Health 120
2. Lion - Attack 10 - Health 90
Enter your selection: 1
Crocodile and Bull are fighting in water
Crocodile remaining health is 97. Bull remaining health is 104
******************
CHOOSE 2 ANIMALS TO FIGHT:
Choose your 1st animal:
0. Crocodile - Attack 8 - Health 97
1. Bull - Attack 6 - Health 104
2. Lion - Attack 10 - Health 90
Enter your selection: 2
Choose your 2nd animal:
0. Crocodile - Attack 8 - Health 97
1. Bull - Attack 6 - Health 104
2. Lion - Attack 10 - Health 90
Enter your selection: 1
Lion and Bull are fighting in water
Lion remaining health is 78. Bull remaining health is 84
******************
CHOOSE 2 ANIMALS TO FIGHT:
Choose your 1st animal:
0. Crocodile - Attack 8 - Health 97
1. Bull - Attack 6 - Health 84
2. Lion - Attack 10 - Health 78
Enter your selection: