« All Events
5 PM – Intro To Java – Gamas
April 23, 2022 @ 5:00 pm - 6:00 pm
Today We Do
- We continued on MonsterInheritance project.
- We made sure this project has Monster class which has String species, int health, int maxDamage.
- We added Monster.doDamage(int amount) which will reduce Monster.health.
- We added attack menu after user selected a monster.
Homework
- Add initializeMonster() method and add 3 monsters to monsterMap:
- dragon, health: 100, maxDamage: 50
- troll, health: 50, maxDamage: 25
- water golem, health: 30, maxDamage: 10
- Call this initializeMonster() inside MonsterInheritanceMain.run() method before the while loop. This way, it is easier to test this project.
- Add “Melee Attack” feature where player attack the selected monster and monster attack the player.
- When player attack the selected monster, the selected monster health will be reduced. Use the monster.doDamage(int amount) method. This is similar to withdrawal mechanism in the quiz.
- When the monster attack the player, the damage would be between 10 and monster.maxDamage. Look at below for expected behavior
-
Please select from one of the following
1. Add new monster
2. List all monsters
3. Play the game
Enter your selection (enter "exit" to quit):3
What is your name: Gamas Chang
How much health you want: 100
Gamas Chang has 100 health remaining.
Please select one of the following monsters:
- troll - health remaining: 50
- dragon - health remaining: 100
- water golem - health remaining: 30
Enter your selection (Enter 'stop' to end the game): troll
What do you want to do with the TROLL:
1. Magic attack
2. Melee attack
3. Arrow attack
4. Heal
Enter your selection:2
How much melee damage do you want to do to the TROLL: 20
You attacked the TROLL with 20 damage and it has 30 healths remaining.
TROLL attacked Gamas Chang and did 14 damage
Gamas Chang has 86 health remaining.
Please select one of the following monsters:
- troll - health remaining: 30
- dragon - health remaining: 100
- water golem - health remaining: 30
Enter your selection (Enter 'stop' to end the game):