« All Events
9 AM – Intro To Java
April 25, 2021 @ 9:00 am - 10:00 am
- We continued with MonsterSystem program. We added the heal, damage and exit feature.
- We installed Android Studio.
- Homework:
- Continue with MonsterSystem program. Inside Monster.java do the following: create 3 methods:
- rangeDamage(int damage)
- melleDamage(int damage)
- magicDamage(int damage, String magicAttackType)
- For now in all of these 3 new methods, just do the same thing as we did with the damage(int damage) method, which is just to reduce the monster’s health by the damage point. Next week we will learn on how to improve this using inheritance.
- Change MonsterSystem second menu to be like this
What do you want to do with the Troll:
1. Magic attack
2. Melle attack
3. Range attack
4. Heal
Enter your selection: 2
How much melle damage you want to do to Troll: 30
You damaged the Troll and it has 10 healths remaining.
- For each of the attacks above, call the appropriate method in Monster. For example, if the user selected “2” for melle attack, you need to call melleDamage(int damage).
- For Magic attack, you need to ask the user 2 question, the damage and magic type. Look at below for example:
What do you want to do with the Troll:
1. Magic attack
2. Melle attack
3. Range attack
4. Heal
Enter your selection: 2
What kind of magic attack you want to do:
1. Fire magic - 10 damage
2. Water magic - 10 damage
3. Earth magic - 12 damage
4. Wind magic - 8 damage
Enter your selection: 1
You damaged the Troll and it has 10 healths remaining.