我正在做一个为房屋建筑商创建清单的项目。我被困在两件事上。 1)一切都在按我的需要运行该类时,它并没有将信息保存到我的字典中。一切运行正常,但是在输入信息以添加房屋后,它不会将房屋添加到Allhomes。因此,我无法检查其他功能是否正常工作,但是如果无法找到房屋,则无法查看其他部分。 2)更新销售状态。写完所有内容后,我不确定现在如何将销售状态作为home_info的一部分进行更新。任何建议都会很棒。
谢谢。
Allhomes = {}
class Home_Inventory:
def __init__(self, squarefeet, address, city, state, zipcode, modelname, salestatus):
self.squarefeet = squarefeet + "square feet"
self.address = address
self.city = city
self.state = state
self.zipcode = zipcode
self.modelname = modelname
self.salestatus = salestatus
def add_home(self):
address = input("Enter address: ")
city = input("Enter city: ")
state = input("Enter state: ")
zipcode = input("Enter zip code: ")
squarefeet = input("Enter square footage: ")
modelname = input("What is the model?: ")
salestatus = input("Is the home sold, available, or under contract?: ")
home_info = Home_Inventory(address, city, state, zipcode, squarefeet + " square feet", modelname, salestatus)
full_address = (address, city, state, zipcode)
home_stats = (squarefeet + " square feet", modelname, salestatus)
Allhomes = {full_address: home_stats}
print("Home added successfully")
def delete_home(self):
delete = input("What is the full address of the home you want to delete?: ")
if delete in Allhomes.keys():
del[delete]
print("The home entered has been deleted.")
else:
print("Address not found")
def sale_status(self):
update = input("What is the full address of the home you want to update?:")
if update in Allhomes.keys():
pass
else:
print("Address not found")
user=True
while user:
print("1. Add to home inventory")
print("2. Remove home from inventory")
print("3. Update sale status")
print("4. View inventory")
print("5. Exit program")
user_wants=input("What would you like to do today?")
if user_wants=="1":
Home_Inventory.add_home(input)
elif user_wants=="2":
Home_Inventory.delete_home(input)
elif user_wants=="3":
Home_Inventory.sale_status(input)
elif user_wants=="4":
print(Allhomes)
elif user_wants=="5":
print("\n Thank you for using home invertory.")
break
elif user_wants!="":
print("\n Input not understood. Please try again.")`