Inheritance. Please see the output required 1. Create House Class with the following properties and methods a.floorSize b. noOfFloors c. noOfDoors d.switchOn() e.lightOpen() f.ovenOpen() 2. Create TownHouse Class inherit the House class 3. Modify the value of the following(noOfFloors and noOfDoors) 4. Instantiate the TownHouse Class once 5. Display all the properties
Python Inheritance. Please see the output required
1. Create House Class with the following properties and methods
a.floorSize
b. noOfFloors
c. noOfDoors
d.switchOn()
e.lightOpen()
f.ovenOpen()
2. Create TownHouse Class inherit the House class
3. Modify the value of the following(noOfFloors and noOfDoors)
4. Instantiate the TownHouse Class once
5. Display all the properties
6. Calling the switchOn() will automatically execute lightOpen() and ovenOpen()
class House:
def __init__(self, floorSize, noOfFloors, noOfDoors):
self.floorSize = floorSize
self.noOfFloors = noOfFloors
self.noOfDoors = noOfDoors
def switchOn(self):
# statements
print("Switch ON")
self.lightOpen()
self.ovenOpen()
def lightOpen(self):
print("Light Open")
def ovenOpen(self):
print("Oven Open")
class TownHouse(House):
def __init__(self, noOfFloors, noOfDoors):
super().__init__(self, noOfFloors, noOfDoors)
t = TownHouse(4, 150)
t.switchOn()
Trending now
This is a popular solution!
Step by step
Solved in 2 steps