def prompt_init(): parent_init = Property.prompt_init() laundry = get_valid_input( "What laundry facilities does " "the property have? ", Apartment.valid_laundries) balcony = get_valid_input("Does the property have a balcony? ", Apartment.valid_balconies) parent_init.update({"laundry": laundry, "balcony": balcony}) return parent_init
def add_property(self): property_type = get_valid_input("What type of property? ", ("house", "apartment")).lower() payment_type = get_valid_input("What payment type? ", ("purchase", "rental")).lower() PropertyClass = self.type_map[(property_type, payment_type)] init_args = PropertyClass.prompt_init() self.property_list.append(PropertyClass(**init_args))
def prompt_init(): parent_init = Property.prompt_init() fenced = get_valid_input("Is the yard fenced? ", House.valid_fenced) garage = get_valid_input("Is there a garage? ", House.valid_garage) num_stories = input("How many stories? ") parent_init.update({ "fenced": fenced, "garage": garage, "num_stories": num_stories }) return parent_init
def prompt_init(): return dict( rent=input("What is the monthly rent? "), utilities=input( "What are the estimated utilities? "), furnished = get_valid_input( "Is the property furnished? ", ("yes", "no")))
class Apartment(Property): valid_laundries = ("coin", "ensuite", "none") valid_balconies = ("yes", "no", "solarium") def __init__(self, balcony='', laundry='', **kwargs): super().__init__(**kwargs) self.balcony = balcony self.laundry = laundry def display(self): super().display() print("APARTMENT DETAILS") print("laundry: {}".format(self.laundry)) print("has balcony: {}".format(self.balcony)) def prompt_init(): parent_init = Property.prompt_init() laundry = get_valid_input( "What laundry facilities does " "the property have? ", Apartment.valid_laundries) balcony = get_valid_input("Does the property have a balcony? ", Apartment.valid_balconies) parent_init.update({"laundry": laundry, "balcony": balcony}) return parent_init prompt_init = staticmethod(prompt_init) get_valid_input("what is the laundry matter?", ("coin", "ensuite", "none"))