def __init__(self, family_name, pension_one, pension_two): super().__init__(family_name, pension_one + pension_two, members_count=2) self.room_cost = 15 self.appliances = [TV(), Fridge(), Stove(), TV(), Fridge(), Stove()] self.calculate_expenses(self.appliances)
def __init__(self, family_name: str, pension_one: float, pension_two: float): super().__init__(name=family_name, budget=(pension_one + pension_two), members_count=2) self.appliances = [TV(), Fridge(), Stove(), TV(), Fridge(), Stove()] self.calculate_expenses(self.appliances)
class OldCouple(Room): room_cost = 15 appliances = [TV(), Fridge(), Stove(), TV(), Fridge(), Stove()] def __init__(self, family_name: str, pension_one: float, pension_two: float): super().__init__(family_name, pension_one + pension_two, 2) self.calculate_expenses(self.appliances)
def __init__(self, family_name: str, salary_one, salary_two): super().__init__(family_name, salary_one + salary_two, 2) self.room_cost = 20 self.appliances = [ TV(), Fridge(), Stove(), Laptop(), TV(), Fridge(), Stove(), Laptop() ] self.calculate_expenses(self.appliances)
def __get_appliances(self): tv = self.members_count * TV() stove = self.members_count * Stove() fridge = self.members_count * Fridge() [self.appliances.append(obj) for obj in tv] [self.appliances.append(obj) for obj in stove] [self.appliances.append(obj) for obj in fridge]
def __init__(self, family_name: str, pension_one: float, pension_two: float): super().__init__(family_name, budget=pension_one + pension_two, members_count=2) self.room_cost = 15 self.appliances = [TV(), Fridge(), Stove()] * 2 self.expenses = self.calculate_expenses(self.appliances)
class OldCouple(Room): room_cost = 15 appliances = [TV(), Fridge(), Stove()] def __init__(self, family_name: str, pension_one: float, pension_two: float): super().__init__(name = family_name, budget=pension_one + pension_two, members_count=2) self.appliances *= 2 self.calculate_expenses(*self.appliances)
def __init__(self, family_name: str, pension_one, pension_two): super().__init__(family_name, budget=pension_one + pension_two, members_count=2) self.appliances = self.appliances = [ TV() for _ in range(self.members_count) ] + [Stove() for _ in range(self.members_count) ] + [Fridge() for _ in range(self.members_count)] self.calculate_expenses(self.appliances)
def test_room_calculate_expenses__expect_calculation_of_all_costs_for_one_month( self): self.room.children = [Child(5, 5, 5), Child(4, 6, 2)] appliances = [Fridge(), Laptop(), Stove(), TV()] self.room.calculate_expenses(self.room.children, appliances) expected_cost = 942 actual_cost = self.room.expenses self.assertEqual(expected_cost, actual_cost)
class OldCouple(Room): _adults_count: ClassVar[int] = 2 _default_room_cost: ClassVar[int] = 15 _default_appliances: ClassVar[List[Appliance]] = [TV(), Fridge(), Stove()] def __init__(self, family_name: str, pension1: float, pension2: float) -> None: super().__init__(family_name, pension1+pension2, self._adults_count) self.appliances = self._default_appliances * self._adults_count self.calculate_expenses(self.appliances)
def __init__(self, family_name: str, pension_one: float, pension_two: float): super().__init__(family_name, (pension_one + pension_two), 2) self.room_cost = 15 tv = TV() fridge = Fridge() stove = Stove() self.appliances = [tv, tv, fridge, fridge, stove, stove] self.expenses = sum([a.get_monthly_expense() for a in self.appliances])
def __init__(self, family_name: str, pension_one: float, pension_two: float): super().__init__(family_name, budget=pension_one + pension_two, members_count=2) self.budget = pension_one + pension_two self.room_cost = 15 self.appliances = [ TV(), Fridge(), Stove() ] * self.members_count # a tv, a fridge and a stove for each person self.calculate_expenses(self.appliances)
def __init__(self, family_name: str, salary_one, salary_two, *children): super().__init__(family_name, salary_one + salary_two, 2 + len(children)) self.room_cost = 30 self.children = children self.appliances = ([ TV(), Fridge(), Stove(), Laptop(), TV(), Fridge(), Stove(), Laptop() ]) for _ in range(len(children)): self.appliances.append([TV(), Fridge(), Laptop()]) self.calculate_expenses(*self.appliances, children)
def __init__(self, family_name: str, pension_one, pension_two): Room.__init__(self, family_name, budget=None, members_count=2, children=None, expenses=None) self.room_cost = 15 self.budget = pension_one + pension_two self.appliances = [TV(), Fridge(), Stove()] self.expenses = sum([ a.get_monthly_expense() * self.members_count for a in self.appliances ])
def __init__(self, family_name: str, pension_one: float, pension_two: float): super().__init__(name=family_name, budget=pension_one + pension_two, members_count=2) self.room_cost = 15 self.appliances = [Stove(), TV(), Fridge(), Stove(), TV(), Fridge()]
def __init__(self, name, pension_one, pension_two): super().__init__(name, pension_one + pension_two, 2) self.room_cost = 15 self.appliances = [TV(), Fridge(), Stove(), TV(), Fridge(), Stove()] self.calculate_expenses(*self.appliances)
def __init__(self, family_name: str, pension_one: float, pension_two: float): super().__init__(family_name, (pension_one + pension_two), 2) self.room_cost = 15 self.appliances = [TV(), Fridge(), Stove()] * 2 self.expenses = sum(a.get_monthly_expense() for a in self.appliances)
def __init__(self, family_name, pension_one, pension_two): super().__init__(family_name,pension_one + pension_two, 2) self.room_cost = 15 self.appliances = [TV().get_monthly_expense(), Fridge().get_monthly_expense(), Stove().get_monthly_expense()] * 2 self.expenses = sum([x for x in self.appliances])
child_two = Child(3, 2) young_couple_with_children = YoungCoupleWithChildren( "Peterson", 600, 520, child_one, child_two) everland.add_room(young_couple) everland.add_room(young_couple_with_children) print(everland.get_monthly_consumptions()) print(everland.pay()) print(everland.status()) Appliance(10).get_monthly_expense() Fridge().get_monthly_expense() Laptop().get_monthly_expense() Stove().get_monthly_expense() TV().get_monthly_expense() Child(1, 2, 3) AloneOld("BOB", 2) AloneYoung("ROB", 2) OldCouple("Bobby", 1, 2) Room("Room", 2, 3) YoungCouple("Pep", 20, 20) YoungCoupleWithChildren("Bob", 10, 15, Child(1, 2, 3), Child(4, 5, 6)) Everland().add_room(Room("Room", 2, 3)) Everland().get_monthly_consumptions() Everland().pay() Everland().status() if __name__ == "__main__": test_one()