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()
Python
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()
Please display all the properties including
House Floor Size : 150
House No. of Floors: 4
House No. of Doors: 8
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)
print()
t = TownHouse(4, 150)
t.switchOn()
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images