Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Seller:
- def __init__(self, seller_name, budget):
- self.seller_name = seller_name
- self.budget = budget
- self.buildings_for_sale = []
- def add_building(self, building, price):
- if price > self.budget:
- return "You haven't enough money to buy this building."
- self.buildings_for_sale.append(building)
- self.budget -= price
- return f"You add building {building.name} with {building.floors} floors for sale."
- def sell(self, building_name, amount):
- for building in self.buildings_for_sale:
- if building.name == building_name:
- self.budget += amount
- self.buildings_for_sale.remove(building)
- return f"You sold `{building.name}` for {amount}$"
- return "You haven't this building in your list."
- def building_status(self):
- result = "Buildings status:\n"
- for building in self.buildings_for_sale:
- result += f"==== '{building.name}' " + f"with {building.floors} floors" + "\n"
- return result.strip()
- def current_budget(self):
- return f"{self.seller_name}'s budget is {self.budget}$"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement