授業のテスト

2310 ワード

所定のコードを使用して不動産プログラムを作成する
(出力例)
全部で3台売っています.
江南マンション売買10億2010年
麻浦オフィスビルの賃貸料は5億2007年.
宋パビラ月額賃貸500/50 2000年
class House:
    # 매물 초기화
    def __init__(self, location, house_type, deal_type, price, completion_year):
		pass

    # 매물 정보 표시
    def show_detail(self):
        pass
質問する
class House:
    # 매물 초기화
    def __init__(self, location, house_type, deal_type, price, completion_year):
        self.location = location
        self.house_type = house_type
        self.deal_type = deal_type
        self.price = price
        self.completion_year = completion_year

    # 매물 정보 표시
    def show_detail(self):
        print("총 {0}대의 매물이 있습니다.")
        print("{0} {1} {2} {3} {4}년".format(self.location, self.house_type, self.deal_type, self.price, self.completion_year))
gangnam = House("강남", "아파트", "매매", "10억", "2010")
mapo = House("마포", "오피스텔", "전세", "5억", "2007")
songpa = House("송파", "빌라", "월세", "500/50", "2000")

all_house = []
all_house.append(gangnam)
all_house.append(mapo)
all_house.append(songpa)

for house in all_house:
    house.show_detail()
私がやったことです.
「共有x台商品」を繰り返す
class House:
    # 매물 초기화
    def __init__(self, location, house_type, deal_type, price, completion_year):
        self.location = location
        self.house_type = house_type
        self.deal_type = deal_type
        self.price = price
        self.completion_year = completion_year

    # 매물 정보 표시
    def show_detail(self):
        print(self.location, self.house_type, self.deal_type\
              , self.price, self.completion_year)

houses = []
house1 = House("강남", "아파트", "매매", "10억", "2010")
house2 = House("마포", "오피스텔", "전세", "5억", "2007")
house3 = House("송파", "빌라", "월세", "500/50", "2000")
houses.append(house1)
houses.append(house2)
houses.append(house3)

print("총 {0}대의 매물이 있습니다.".format(len(houses)))
for house in houses:
    house.show_detail()
正解
無視:「販売待ちの商品が共有されています.」できない{0}をall houseの長さに指定