American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • This event has passed.

7 PM – Intro To Java – Darin

June 19 @ 7:00 pm - 8:00 pm

 

What We Did Today:

  1. Got started on the monster inheritance program (similar to Python but now we are implementing it in Java)

 

Homework:

Upload your file to your google drive homework section (create a new directory called MonsterInheritance) when you are finished.

In this you are only implementing the printMonsterMenu and play() method.

  1. In the printMonsterMenu method, make it so that when the method is called, you see the following (we already have a method to list monsters, so you need to use System.out.print only two times) and the method should return a string for the monster name:
Please select one of the following monsters:

LIST OF ALL MONSTERS
- Regenerative Troll - 70 health
- Troll - 70 health
- Dragon - 100 health
- Water Golem - 50 health

Enter your selection (Enter 'stop' to end the game):\s""";

2. After you are done with this and the method returns a String value to the play() method and initializes selectedMonster, check if it is equal to “stop” to break out of the while loop.

3. Initialize a new monster object by trying to get a monster from the monsters hashmap using .get() by using selectedMonster as a parameter, and if you are unable to successfully get the monster with the given key (selectedMonster), then the monster object should be initialized to “null”.

4. Check if the new monster object is equal to null, and if it is not, print the attack menu, but you do not need to check for selection just yet.

attack menu:

private String attackMenu = """
        \nWhat do you want to do with the %s:
        1. Magic attack
        2. Melee attack
        3. Arrow attack (5 -10 damage)
        4. Heal
        Enter your selection:\s""";

Notes:

If you have any questions, you may reach out to me at ddjapri@ayclogic.com.

Details

Date:
June 19
Time:
7:00 pm - 8:00 pm
Event Categories:
,
Verified by MonsterInsights