Instance variables :
-Type
-Model
Methods:
-get_Type()- To return in instance variable Type
-get _Model() – To return instance variable Model and Type
Instance variables:
-No_of_seats
-Cost
Methods:
-get_Seats() : To retorn instance variable No_of_seats
-get_Cost() : To return instance variable cost
-show() : To print instance variable No_of_Seats and cost
Furniture class is inherited by class Sofa
In [ ]:
class furniture(object):
'''Class to create a furniture object defined by the following attributes:
Type: Type of furniture
Model: Model of furniture
Methods:-
get_Type(): Returns furniture type of instance
get_Model(): Returns model of instance'''
def __init__(self,type,model):
self.type = type
self.model = model
def get_Type(self):
return self.type
def get_Model(self):
return self.model
class sofa(furniture):
'''Class to create a sofa object which inherits furniture, and is defined by:
No_of_seats
Cost
Methods:-
get_Seats()
get_Cost()
show() : Prints information about number of seats and cost'''
def __init__(self,seats,cost):
super(sofa,self).__init__('sofa','modelA')
self.No_of_seats = seats
self.Cost = cost
def get_Seats(self):
return self.No_of_seats
def get_Cost(self):
return self.Cost
def show(self):
print 'No. of seats: ' + str(self.get_Seats()) + '\n' + 'Cost: ' str(self.get_Cost())