« All Events
7 PM – Python OOP – Gamas
December 18, 2023 @ 7:00 pm - 8:00 pm
Today We Did
- We learned about inheritance with Car and ElectricCar classes.
- We continued with MonsterInheritance adding feature where dragon is immune to fire magic and Troll is resistant with earth magic.
Homework
- No class until January 6th.
- Create a new file dragon.py. Inside this file create Dragon class that inherits from Monster class.
- Inside Dragon class create a method called magic_damage(self, damage, magic_type)
- Inside this method, add code that would make no damage where magic_type is “fire”. Otherwise damage the dragon regularly.
- Create a new file troll.py. Inside this file create Troll class that inherits from Monster class.
- Inside Troll class create a method called magic_damage(self, damage, magic_type)
- Inside this method, add code that would make half damage where magic_type is “earth”. Otherwise damage the dragon regularly.