def add_property(self): """ This method adds a new item to attribute self.property_list. """ 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 if_display(): """ This function asks user if they want to see current properties. :return: (bool) - True if user response is positive, else - False """ resp = get_valid_input("Do you want to see current properties?", ("yes", "no")) if resp == "yes": agent.display_properties() else: resp = get_valid_input("To quit enter 'exit'," " otherwise you'll start from the beginning", "exit") if resp == "exit": return False return True
def prompt_init(): """ This method asks user to enter appropriate info for Apartment instance: first it calls parent method and then asks for additional info, which characterizes an Apartment instance - laundry and balcony. :return: (dict{(str):(str) }) """ 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 prompt_init(): """ This method asks user to enter appropriate info for House instance: first it calls parent method and then asks for additional info, which characterizes a House instance - fence, garage and number of stories. :return: (dict{(str): (str)}) """ 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(): """ This method asks user to enter appropriate info for Rental instance, which characterizes it - rent, utilities and furnished state. :return: (dict{(str): (str)}) """ 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")))
def if_display(): """ This function asks user if they want to see current properties. :return: (bool) - True if user response is positive, else - False """ resp = get_valid_input("Do you want to see current properties?", ("yes", "no")) if resp == "yes": agent.display_properties() else: resp = get_valid_input("To quit enter 'exit'," " otherwise you'll start from the beginning", "exit") if resp == "exit": return False return True agent = Agent() print("============ Welcome to the world of real estate! ============") while True: print() resp = get_valid_input("Do you want to add a new property?", ("yes", "no")) if resp == "yes": agent.add_property() else: if not if_display(): break