class House: def __init__(self, household_name, members, land): self.household_name = household_name self.members = members self.land = land def display_info(self): print("户主名称:", self.household_name) print("家庭成员信息:") for member in self.members: print(member) print("土地信息:", self.land) class HouseholdManagementSystem: def __init__(self): self.houses = [] def add_house(self, household_name, members, land): house = House(household_name, members, land) self.houses.append(house) def display_houses(self): for house in self.houses: house.display_info() # 示例用法 if __name__ == "__main__": hms = HouseholdManagementSystem() # 添加户籍信息 hms.add_house("张三", ["张三", "李四", "王五"], "100平米土地") hms.add_house("李四", ["李四", "赵六"], "80平米土地") # 显示户籍信息 hms.display_houses()
时间: 2024-04-18 14:24:14 浏览: 57
kk.rar_atm_household account
这段代码定义了一个 `House` 类和一个 `HouseholdManagementSystem` 类,用于实现户籍管理系统的功能。在示例用法部分,创建了一个 `HouseholdManagementSystem` 对象,并添加了两个户籍信息。最后,调用 `display_houses` 方法显示所有户籍信息。
如果你对这段代码有任何问题或需要进一步的帮助,请随时提问。
阅读全文