Question
In python, This assignment assumes that you have created the Property class for Homework #5. Create a program that stores property objects in a dictionary.
In python, This assignment assumes that you have created the Property class for Homework #5. Create a program that stores property objects in a dictionary. Use the property ID number as the key. The program should present a menu that lets the user perform the following actions:
- Display a specific property and/or list of all properties based on the property type specified by the user: residential, land, commercial, or all properties.
- Look up a specific property record in the dictionary.
- Add a new property record to the dictionary.
- Change an existing property information for a specified property in the dictionary.
- Sell a property.
- Discount agency fees for all of a specific type of properties in inventory. For example, the real estate agency may decide to reduce all commercial agency fees by 1 percent.
- Delete a property record from the dictionary.
- Quit the program When the program ends, it should pickle the dictionary and save it to a file. Each time the program starts, it should try to load the pickled dictionary from the file. If the file does not exist, the program should start with an empty dictionary.
Make a video demonstrating the operation of your system using the following steps:
1) Display a list of properties - make sure to account for the possibility that there are no properties in the dictionary yet.
2) Create six property objects (using option #3 from your menu). You should create two of each type of property: residential, land, and commercial.
3) Quit the program (using option #8) so that all the properties are saved to a file.
4) Start the program and make sure that the saved properties are read in so they can be used by your program.
5) Display a list of properties so the user can see what properties are available to choose from.
6) Select a specific property and change the attribute values.
7) Display the specific property you just changed to demonstrate the new values.
8) Sell a property.
9) Apply a discount to the agency fees for a particular type of property that was just sold.
10) Display the list of properties, for the type selected in step 8, to demonstrate that the changes were made by steps #8 and #9.
11) Delete a particular property.
12) Demonstrate that the property was deleted by display a list of properties (either all properties, a list of the type of properties, or a specific property that would then display a message that the specific property was not found).
13) Quit the program (using option #8) so that all the properties are saved to a file. Make sure to attach your .dat file and upload it along with your program (both the class file and the text file), and your video recording when you submit your solution. The recording will help verify that all of your menu selections work.
Homework #5:
class Property_Inventory: auto_id = 1 property_inventory = [] def __init__(self, address, city, state, zip_code, status="for sale", price=0, beds=0, baths=0, type="residential", agency_fee=3.00): self.__id = Property_Inventory.auto_id Property_Inventory.auto_id += 1 self.__address = address self.__city = city self.__state = state self.__zip_code = zip_code self._status = status self._price = float(price) self.__beds = int(beds) self.__baths = int(baths) self._type = type self._agency_fee = agency_fee Property_Inventory.property_inventory.append(self) #adds the property to the inventory def set_state(self, state): if len(state) == 2 and state.isalpha(): #validates that the user only enters two characters and that its only alphabetic letters self.__state = state.upper() #sets the state and converts it to upper, if typed lowercase it uppers else: #else the state is invalid it sets to ?? self.__state = "??" def set_zip(self, zip_code): if len(zip_code) == 5 and zip_code.isdigit(): #verifies the zip code has length of 5 and contains only digits and stores it in a string self.__zip_code = zip_code #if the zip has a leading zero the zeros will display else: self.__zip_code = "00000" def set_beds(self, beds): if self._type == "land" or self._type == "commercial": #sets the number of bedrooms the property has if in land or commercial it should be set to zero self.__beds = 0 else: self.__beds = beds def set_baths(self, baths): if self._type == "land": #stores the number of bathrooms at the property, for land it is set to 0 self.__baths = 0 else: self.__baths = baths def display_all_properties(self, property_type="", property_status=""): #takes a propety type and status and displays all properties that match the type and status for prop in self.property_inventory: if (not property_type or prop._type == property_type) and (not property_status or prop._status == property_status): #checks if property matches the specified 'type' and 'status' print(prop) def discount_agency_fee(self, discount, property_type): #decreases the agency fee by discount value and type passed for not sold properties for prop in self.property_inventory: if prop._type == property_type and prop._status != "sold": #checks if property is not sold and matches the matching property type prop._agency_fee -= discount def mark_sold(self, sales_price): ##change the property status to "sold" and set the price to the sales price passed to the method. if self._status != "sold": self._status = "sold" self._price = sales_price #sets property price to sales_price def __str__(self): #returns string reprensentation of listings return f"Property ID: {self.__id} Address: {self.__address}, {self.__city}, {self.__state} {self.__zip_code} Status: {self._status} Price: ${self._price:.2f} Beds: {self.__beds} Baths: {self.__baths} Type: {self._type} Agency Fee: {self._agency_fee}%"
Step by Step Solution
There are 3 Steps involved in it
Step: 1
To implement the program described in your assignment you can use the following code This code extends the PropertyInventory class and adds a menudriv...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started