示例#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))
示例#2
0
文件: usl.py 项目: 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)
示例#3
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, "个")
示例#4
0
文件: usl.py 项目: seabedforest/study
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))
示例#5
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__)