The class jiaju:
Def __init__ (self, name, pingmi) :
The self. The name=name
Self. Pingmi=pingmi
Def the __str__ (self) :
Return "[% s] stand to % 2 f square meters" % (self. The name, the self. Pingmi)
Y=jiaju (" bench ", 4)
X=jiaju (" table ", 9)
J=jiaju (" sofa ", 10)
Print (y)
Print (x)
Print (j)
The class fangzi:
Def __init__ (self, house_tpye arse) :
Self. House_tpye=house_tpye
The self. The arse=arse
# residual area
Self. Feaa_arse=arse
# furniture name list
Self. Item_list=[]
Def the __str__ (self) :
Return (" family: % s \ n the total area: % 2 f [%. The remaining 2 f] \ n furniture: % s "% (self. House_tpye, self arse, self feaa_arse, self. Item_list))
Def add_item (self, item) :
Print (" to add % s "% item)
If the item. Arse & gt; Feaa_arse:
Return
Selfitem_list. Append (item name)
Self. Feaa_arse -=arse
My_house=fangzi (" two rooms one hall, "60)
My_house=add_item (y)
Print (my_house)