Ejemplo n.º 1
0
class HouseManagerView:
    def __init__(self):
        self.__controller = HouseManagerController()

    def __display_menu(self):
        print("1键显示所有房源信息")
        print("2键显示总价最高的房源信息")
        print("3键显示面积最小的房源信息")
        print("4键根据总价升序显示房源信息")
        print("5键根据面积降序显示房源信息")
        print("6键查看房源类型信息")

    def __select_menu(self):
        item = input("请输入选项:")
        if item == "1":
            self.__show_houses()
        elif item == "2":
            self.__show_house_by_max_total_price()
        elif item == "3":
            self.__show_house_by_min_area()
        elif item == "4":
            self.__show_houses_by_ascending_total_price()
        elif item == "5":
            self.__show_houses_by_descending_area()
        elif item == "6":
            self.__show_house_type()

    def __show_houses(self):
        for house in self.__controller.list_houses:
            # 直接打印对象,由对象的__str__方法决定打印风格
            print(house)

    def main(self):
        while True:
            self.__display_menu()
            self.__select_menu()

    def __show_house_by_max_total_price(self):
        house = self.__controller.get_house_by_max_total_price()
        print(house)

    def __show_house_by_min_area(self):
        house = self.__controller.get_house_by_min_area()
        print(house)

    def __show_houses_by_ascending_total_price(self):
        list_result = self.__controller.ascending_by_total_price()
        for item in list_result:
            print(item)

    def __show_houses_by_descending_area(self):
        list_result = self.__controller.descending_by_area()
        for item in list_result:
            print(item)

    def __show_house_type(self):
        dict_house_type = self.__controller.get_house_type()
        for key, value in dict_house_type.items():
            print("%s的房子有%d个" % (key, value))
Ejemplo n.º 2
0
class HouseView:
    def __init__(self):
        self.__housem = HouseManagerController()

    def __menu_show(self):
        print("按1显示房源")
        print("2键显示总价最高的房源信息")
        print("3键显示面积最小的房源信息")
        print("4键根据总价升序显示房源信息")
        print("按5键根据面积降序显示房源信息")
        print("6键查看房源类型信息")
        self.__menu_select()

    def __menu_select(self):
        menu_number = int(input("请输入您的数字:"))
        if menu_number == 1:
            self.__show_houses()
        if menu_number == 2:
            self.__find_the_max_price()
        if menu_number == 3:
            self.__find_smallest_area()
        if menu_number == 4:
            self.__up_order_list()
        if menu_number == 5:
            self.__downsing_order()
        if menu_number == 6:
            self.__check_the_info_in_the_dict()

    def __show_houses(self):
        for house in self.__housem.list_houses:
            # 直接打印对象,由对象的__str__方法决定打印风格
            print(house.__dict__)

    def main(self):
        while 1:
            self.__menu_show()
            self.__menu_select()

    def __find_the_max_price(self):
        print(self.__housem.find_the_max_price().__dict__)

    def __find_smallest_area(self):
        print(self.__housem.find_smallest_area().__dict__)

    def __up_order_list(self):
        t4 = self.__housem.up_order_list()
        for ttt4 in t4:
            print(ttt4.__dict__)

    def __downsing_order(self):
        t5 = self.__housem.downsiding_order()
        for ttt5 in t5:
            print(ttt5.__dict__)

    def __check_the_info_in_the_dict(self):
        t6 = self.__housem.check_the_info_in_the_dict()
        for k, v in t6.items():
            print(f"{k}的房子一共有{v}个")
Ejemplo n.º 3
0
class HouseView:
    def __init__(self):
        self.__controller = HouseManagerController()

    def __display_menu(self):  #显示菜单
        print("1 显示所有房源信息")
        print("2 删除所有房源信息")
        print("3 显示最高房价房源")
        print("4 显示最低房价房源")
        print("5 显示户型种类")

    def __select_menu(self):
        selection = input("请输入选项:")
        if selection == "1":
            self.__show_house()  #alt+ENTER创建
        elif selection == "2":
            self.__delte_house()
        elif selection == "3":
            self.__show_max_price()
        elif selection == "4":
            self.__show_min_price()
        elif selection == "5":
            self.__show_house_type()

    def main(self):
        while True:
            self.__display_menu()
            self.__select_menu()

    def __show_house(self):
        house = HouseModel()
        for house in self.__controller.list_houses:
            # print(f"{house.title}的房源编号是{house.id}社区是{house.community}"
            #       f"楼龄是{house.years}房屋类型是{house.house_type}房屋面积是{house.area}"
            #       f"楼层是{house.floor}描述是{house.description}总价是{house.total_price}"
            #       f"单价是{house.unit_price}关注{house.follow_info}")
            print(house.__dict__)

    def __delte_house(self):
        id = int(input("请输入要删除的房源编号"))
        if self.__controller.delete_house(id):
            print("删除成功")
        else:
            print("删除失败")

    def __show_max_price(self):
        print(self.__controller.calculate_max_price().__dict__)

    def __show_min_price(self):
        print(self.__controller.calculate_min_price().__dict__)

    def __show_house_type(self):
        for k, v in self.__controller.calculate_house_type().items():
            print(k, v)
Ejemplo n.º 4
0
class HouseManagerView:
    def __init__(self):
        self.__controller = HouseManagerController()

    def __display_menu(self):
        print("按1键显示所有房源信息")
        print("按2键显示总价最高的房源信息")
        print("按3键显示面积最小的房源信息")
        print("按4键根据总价升序显示房源信息")
        print("按5键根据面积降序显示房源信息")
        print("按6键查找所有户型信息")

    def __select_menu(self):
        selection = input("请输入您的选择:")
        if selection == "1":
            self.__display_all_house_info()
        elif selection == "2":
            self.__display_most_expenseve_house_info()
        elif selection == "3":
            self.__display_smallest_house_info()
        elif selection == "4":
            self.__display_ascending_house_info_by_total_price()
        elif selection == "5":
            self.__display_descending_house_info_by_area()
        elif selection == "6":
            self.__display_all_house_type_info()

    def __display_all_house_info(self):
        for item in self.__controller.list_house:
            print(item)

    def main(self):
        while True:
            self.__display_menu()
            self.__select_menu()

    def __display_most_expenseve_house_info(self):
        print(self.__controller.get_most_expensive_house_info())

    def __display_smallest_house_info(self):
        print(self.__controller.get_smallest_house_info())

    def __display_ascending_house_info_by_total_price(self):
        for item in self.__controller.ascending_house_info_by_total_price():
            print(item)

    def __display_descending_house_info_by_area(self):
        for item in self.__controller.descending_house_info_by_area():
            print(item)

    def __display_all_house_type_info(self):
        for key,value in self.__controller.house_type_info().items():
            print(key,value)
Ejemplo n.º 5
0
class HouseManagerView:
    def __init__(self):
        self.__controller = HouseManagerController()

    def __display_menu(self):
        print("1键查看所有房源信息")
        print("2键查看总价最高的房源信息")
        print("3键查看面积最小的房源信息")
        print("4键显示户型种类")

    def __select_menu(self):
        item = input("请输入选项:")
        if item == "1":
            self.__display_houses()
        elif item == "2":
            self.__output_house_by_max_total_price()
        elif item == "3":
            self.__output_house_by_min_area()
        elif item == "4":
            self.__output_houses_type()

    def main(self):
        while True:
            self.__display_menu()
            self.__select_menu()

    def __display_houses(self):
        for house in self.__controller.list_houses:
            self.__show_house(house)

    def __output_house_by_max_total_price(self):
        house = self.__controller.get_house_by_max_total_price()
        self.__show_house(house)

    def __show_house(self, house: HouseModel):
        print("%d|%s|%s|%s+|%s|%s|%s|%s|%d|%d|%s" %
              (house.id, house.title, house.community, house.years,
               house.house_type, house.area, house.floor, house.description,
               house.total_price, house.unit_price, house.follow_info))

    def __output_house_by_min_area(self):
        house = self.__controller.get_house_by_min_area()
        self.__show_house(house)

    def __output_houses_type(self):
        for type, count in self.__controller.get_houses_type().items():
            print(type, "有", count, "个")
Ejemplo n.º 6
0
class HouseManager:
    def __init__(self):
        self.__controller = HouseManagerController()
        self.secede = True

    def __display_menu(self):
        print("1.txt) 显示所有房源信息")
        print("2) 显示最贵的房源信息")
        print("3) 显示最小面积的房源")
        print("4) 获取所有户型种类{ 户型 : 数量 }")
        print("5) 退出")

    def __select_menu(self):
        item = input("请输入选项:")
        if item == "1.txt":
            self.__display_house()
        elif item == "2":
            self.__show_max_price()
        elif item == "3":
            self.__show_min_area()
        elif item == "4":
            self.__show_house_type()
        elif item == "5":
            self.secede = False

    def __display_house(self):
        for house in self.__controller.list_houses:
            print(house.__dict__)

    def main(self):
        while self.secede:
            self.__display_menu()
            self.__select_menu()

    def __show_max_price(self):
        house = self.__controller.get_house_by_max_price()
        print(house.__dict__)

    def __show_min_area(self):
        house = self.__controller.get_house_by_min_area()
        print(house.__dict__)

    def __show_house_type(self):
        dict_house_type = self.__controller.get_house_type()
        for k, v in dict_house_type.items():
            print("户型是%s,数量是%d" % (k, v))
Ejemplo n.º 7
0
class HouseManagerView:
    """
        # 学生视图:负责处理界面逻辑(输入/输出/界面跳转)
    """
    def __init__(self):
        self.__controller = HouseManagerController()

    def main(self):
        while True:
            self.__display_menu()
            self.__select_menu()

    def __display_menu(self):
        print("1) 显示所有房源")
        print("2) 显示最贵的房源")
        print("3) 显示最小的房源")

    def __select_menu(self):
        item = input("请输入选项:")
        if item == "1":
            self.__display_houses()
        elif item == "2":
            self.__display_house_by_max_price()
        elif item == "3":
            self.__display_house_by_min_area()

    def __display_houses(self):
        for house in self.__controller.list_houses:
            # 定义打印房源的格式
            print(house.__dict__)

    def __display_house_by_max_price(self):
        house = self.__controller.get_house_by_max_price()
        # {'id': 8571, 'title': '中关村创业大街对过 有名的公司入驻其中正规写字楼', 'community': '银科大厦', 'years': '低楼层(共22层)2004年建塔楼', 'house_type': '1室0卫', 'area': 2623.28, 'floor': '低楼层(共22层)2004年建塔楼', 'description': '距离10号线苏州街站898米房本满五年', 'total_price': 120001943.60000001, 'unit_price': 45745.0, 'follow_info': '1人关注 / 共0次带看 / 2个月以前发布'}
        print(house.__dict__)

    def __display_house_by_min_area(self):
        house = self.__controller.get_house_by_min_area()
        # {'id': 15260, 'title': '智德北巷(北河沿大街)+小户型一居+南向', 'community': '智德北巷', 'years': '中楼层(共6层)1985年建板楼', 'house_type': '1室0厅', 'area': 15.29, 'floor': '中楼层(共6层)1985年建板楼', 'description': '距离5号线灯市口站1113米', 'total_price': 2200001.65, 'unit_price': 143885.0, 'follow_info': '56人关注 / 共2次带看 / 8天以前发布'}
        print(house.__dict__)
Ejemplo n.º 8
0
Archivo: usl.py Proyecto: yegeli/month1
class HouseManagerView:
    def __init__(self):
        self.__manager = HouseManagerController()

    def __display_menu(self):
        print("1键查看总价最高的房源信息")
        print("2键查看面积最小的房源信息")
        print("3键显示户型种类")
        print("4键查看全部房源信息")

    def __select_menu(self):
        item = input("请输入选项:")
        if item == "1":
            self.__output_house_by_max_total_price()
        elif item == "2":
            self.__output_house_by_min_area()
        elif item == "3":
            self.__output_houses_type()
        elif item == "4":
            self.__output_houses_by_all()

    def main(self):
        while True:
            self.__display_menu()
            self.__select_menu()

    def __output_house_by_max_total_price(self):
        house = self.__manager.get_house_by_max_total_price()
        self.__show_house(house)

    def __show_house(self, house: HouseModel):
        print("%d|%s|%s|%s+|%s|%s|%s|%s|%d|%d|%s" %
              (house.id, house.title, house.community, house.years,
               house.house_type, house.area, house.floor, house.description,
               house.total_price, house.unit_price, house.follow_info))

    def __output_house_by_min_area(self):
        house = self.__manager.get_house_by_min_area()
        self.__show_house(house)

    def __output_houses_type(self):
        for k, v in self.__manager.get_houses_type().items():
            print(k, "有", v, "个")

    def __output_houses_by_all(self):
        item = input("""a键根据编号升序查看\nb键根据单价降序查看\nc键根据关注人数降序查看""")
        result = None
        if item == "a":
            result = self.__manager.ascending_by_id()
        elif item == "b":
            result = self.__manager.descending_by_unit_price()
        elif item == "c":
            result = self.__manager.descending_by_attention()
        if result:
            for house in result:
                self.__show_house(house)
Ejemplo n.º 9
0
class HouseView:
    def __init__(self):
        self.__control = HouseManagerController()

    def __display_menu(self):
        print("1:显示所有房源信息")
        print("2:显示总价格最大房子")
        print("3:显示总面积最小房子")
        print("4:显示房型数量")
        print("5:删除房子信息")
        print("6:对房子价格升序")

    def __select_menu(self):
        select = input_select("选项")
        if select == 1:
            self.__show_house_informaitin()
        elif select == 2:
            # house = self.__control.get_house_max_total_price()
            # house = IterableHelper.get_max(self.__control.get_house_list(),lambda house: house.total_price)
            house = max(self.__control.get_house_list(),
                        key=lambda house: house.total_price)
            print(house.__dict__)
        elif select == 3:
            # house = self.__control.get_house_min_area()
            # house = min(self.__control.get_house_list(), key=lambda house: house.area)
            house = min(self.__control.get_house_list(),
                        key=lambda house: house.id)
            print(house.__dict__)
        elif select == 4:
            print(self.__control.count_house_type())
            pass
        elif select == 5:
            id = input_select("房源编号")
            # if self.__control.del_house_by_id(id):
            if IterableHelper.del_single_by_info(self.__control.__list_houses,
                                                 lambda house: house.id == id):
                print("删除成功")
            else:
                print("删除失败,没找到此房源")
        elif select == 6:
            self.__control.ascending_ording()
            for house in sorted(self.__control.__list_houses,
                                key=lambda house: house.total_price):
                print(house.__dict__)

    def __show_house_informaitin(self):
        for house in self.__control.get_house_list():
            print(house.__dict__)

    def main(self):
        """
            入口函数
        """
        while True:
            self.__display_menu()
            self.__select_menu()
Ejemplo n.º 10
0
 def __init__(self):
     self.__controller = HouseManagerController()
Ejemplo n.º 11
0
class HouseManagerView:
    def __init__(self):
        self.controller = HouseManagerController()

    def show_menu(self):
        print("输入1显示房源信息")
        print("输入2显示总价最高的房源信息")
        print("输入3显示面积最小的房源信息")
        print("按4根据总价升序显示房源信息")
        print("按5根据面积降序显示房源信息")
        print("按6查找所有户型信息 ")

    def select(self):
        choice = input("请输入你的选择")
        if choice == "1":
            self.controller.show_all_info()
        if choice == "2":
            self.controller.show_highest_price_info()
        if choice == "3":
            self.controller.show_smallest_area_info()
        if choice == "4":
            self.controller.ascending_by_total_price()
        if choice == "5":
            self.controller.descending_by_area()
        if choice == "6":
            self.controller.show_all_house_type_info()

    def main(self):
        view = HouseManagerView()
        while True:
            view.show_menu()
            view.select()
Ejemplo n.º 12
0
class HouseManagerView:
    def __init__(self):
        self.__controller = HouseManagerController()

    def __display_menu(self):
        print("1) 显示所有房源信息")
        print("2) 显示总价最高的房源信息")
        print("3) 显示面积最小的房源信息")
        print("4) 根据总价升序显示房源信息")
        print("5) 根据面积降序显示房源信息")
        print("6) 查找所有户型信息")

    def __select_menu(self):
        number = input("请输入选项:")
        if number == "1":
            self.__show_all_house_info()

        elif number == "2":
            self.__get_max_total_price()

        elif number == "3":
            self.__get_min_area()

        elif number == "4":
            self.__order_by_total_price()

        elif number == "5":
            self.__order_by_area()

        elif number == "6":
            self.__find_house_type_info()

    def main(self):
        while True:
            self.__display_menu()
            self.__select_menu()

    def __show_all_house_info(self):
        for item in self.__controller.list_houses:
            print(item)

    def __get_max_total_price(self):
        print(self.__controller.get_max_price())

    def __get_min_area(self):
        print(self.__controller.get_min_area())

    def __order_by_total_price(self):
        list_result = self.__controller.order_by_price()
        for item in list_result:
            print(item)

    def __order_by_area(self):
        list_result = self.__controller.order_by_area()
        for item in list_result:
            print(item)

    def __find_house_type_info(self):
        dict_result = self.__controller.find_house_type()
        for k, v in dict_result.items():
            print(f"{k} {v}个")
Ejemplo n.º 13
0
 def __init__(self):
     self.__controller = HouseManagerController()
     self.secede = True
Ejemplo n.º 14
0
Archivo: usl.py Proyecto: b63865377/-
class HouseManagerView:
    """
       责处理界面逻辑(输入/输出/界面跳转)
    """
    def __init__(self):
        self.__controller = HouseManagerController()

    # def main(self):
    #     while True:
    #         self.__display_menu()
    #         self.__select_menu()
    #
    # def __display_menu(self):
    #     print("1) 显示所有房源")
    #     print("2)   ")
    #     print("3)  ")
    #
    # def __select_menu(self):
    #     item = input("请输入选项:")
    #     if item == "1":
    #         self.__display_houses()
    #     elif item == "2":
    #         pass
    #     elif item == "3":
    #         pass
    #
    # def __display_houses(self):
    #     for house in self.__controller.list_houses:
    #         # 定义打印房源的格式....
    #         print(house.__dict__)

    def __display_room(self):
        print('按1键显示所有房源信息')
        print('按2键显示最贵的房源信息')
        print('按3键显示最小的房源信息')

    def __select_menu(self):
        item = input("请输入选项:")
        if item == '1':
            self.__showroomiofo()
        if item == '2':
            self.__find_expensive_room()
        if item == '3':
            self.__find_min_area_room()
        if item == '4':
            self.__get_house_type()

    def __showroomiofo(self):
        for item in self.__controller.list_houses:
            print(item.__dict__)

    def main(self):
        while True:
            self.__display_room()
            self.__select_menu()

    def __find_expensive_room(self):
        expensive_room = self.__controller.getexpensive()
        print(expensive_room.__dict__)

    def __find_min_area_room(self):
        min_area_room = self.__controller.get_min_area()
        print(min_area_room.__dict__)

    def __get_house_type(self):
        listhouse = self.__controller.find_house_type_number()
        print(listhouse)