- This event has passed.
3 PM – Python OOP – Allison
July 30, 2025 @ 3:00 pm - 4:00 pm
- Upload your homework as July30_main.py and water_golem.py
- Create a new file called water_golem.py
- Create a class called WaterGolem. This class will be a child of the Monster class.
- This class will have 2 attributes: health and max_attack
- Make sure to set up using the parent’s __init__ function.
- Create receive_magic_attack() function that will take in 2 parameters: damage_point and magic_type
- If magic_type is fire:
- Print: Water Golem is immune to fire attack. Therefore, the Water Golem suffer no damage
- If magic_type is water:
- Print: Water Golem is resistance to water attack. Therefore, your attack is halved.
- Subtract half the damage points from health
- Otherwise:
- Call the parent’s receive_magic_attack function
- If magic_type is fire:
- In your main.py
- In your initialize_monsters function, add the below to monster_dictionary:
- A watergolem with health 30 and max attack of 20
- A vampire (this is a Monster object) with health 45 and max attack of 15
- Create a new function called display_strong_monster():
- Loop through all monsters in monster_dictionary. If a monster’s health is > 50, print out that monster’s information using .get_info() function
- If the user enters 4, call display_strong_monster()
- In your initialize_monsters function, add the below to monster_dictionary:
- Other
- Add any missing parts of your class notes from our class notes (see link at bottom)
- Review the homework answers (see link at bottom)
Notes
- You can reach out via allison@ayclogic.com if you have any questions.
- Class notes and previous homework answers can be found here: Link to Google Drive