« All Events
10 AM – Python OOP – Indo – Gamas
January 26 @ 10:00 am - 11:00 am
Today We Did
- We learned about inheritance in Car and ElectricCar classes.
- We learned on how to make a class inherits another class.
- We learned inherits means a child class (ElectricCar) gets all the attributes and methods of its parent class (Car).
- We learned on how to override parent’s method.
Homework
- Inside monster_inheritance project, create a new file dragon.py.
- Inside dragon.py, create a new class called Dragon.
- The Dragon class has to inherits form Monster class.
- Inside the Dragon class, override def magic_attack(self, damage, magic_type) method so when the dragon get water magic_type the damage will be doubled. And also say, “Dragon is weak against water magic, hence the damage is doubled. 2 x 50 damages”. We did method override earlier in the car inside ElectricCar.add_more_gasoline(self, amount) method.