American Young Coder

AYC logo
Loading Events

« All Events

  • This event has passed.

3 PM – Python OOP – Allison

July 30 @ 3:00 pm - 4:00 pm

  1. Upload your homework as July30_main.py and water_golem.py
  2. Create a new file called water_golem.py
    1. Create a class called WaterGolem. This class will be a child of the Monster class.
    2. This class will have 2 attributes: health and max_attack
    3. Make sure to set up using the parent’s __init__ function.
    4. Create receive_magic_attack() function that will take in 2 parameters: damage_point and magic_type
      1. If magic_type is fire:
        1. Print: Water Golem is immune to fire attack. Therefore, the Water Golem suffer no damage
      2. If magic_type is water:
        1. Print: Water Golem is resistance to water attack. Therefore, your attack is halved.
        2. Subtract half the damage points from health
      3. Otherwise:
        1. Call the parent’s receive_magic_attack function
  3. In your main.py
    1. In your initialize_monsters function, add the below to monster_dictionary:
      1. A watergolem with health 30 and max attack of 20
      2. A vampire (this is a Monster object) with health 45 and max attack of 15
    2. Create a new function called display_strong_monster():
      1. Loop through all monsters in monster_dictionary. If a monster’s health is > 50, print out that monster’s information using .get_info() function
    3. If the user enters 4, call display_strong_monster()
  4. Other
    1. Add any missing parts of your class notes from our class notes (see link at bottom)
    2. Review the homework answers (see link at bottom)

Notes

  1. You can reach out via allison@ayclogic.com if you have any questions.
  2. Class notes and previous homework answers can be found here: Link to Google Drive

Details

Date:
July 30
Time:
3:00 pm - 4:00 pm
Event Categories:
,