コード例 #1
0
    def test_calculate_expenses_when_more_consumers(self):
        children = [Child(10, 5, 6), Child(5, 5, 5)]
        appliances = [Appliance(15)]
        self.room.calculate_expenses(children, appliances)

        expected = children[0].get_monthly_expense() + children[
            1].get_monthly_expense() + appliances[0].get_monthly_expense()

        self.assertEqual(expected, self.room.expenses)
コード例 #2
0
    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)
コード例 #3
0
    def test__calculate_expenses_when_two_consumers__expect_expenses_to_be_correct(
            self):
        appliances = [Child(1, 2, 3, 4)]
        children = [Child(5, 1, 2, 3)]

        self.room.calculate_expenses(appliances, children)
        expected = appliances[0].get_monthly_expense(
        ) + children[0].get_monthly_expense()

        self.assertEqual(expected, self.room.expenses)
コード例 #4
0
def test_one():
    young_couple = YoungCouple("Johnsons", 150, 205)

    child1 = Child(5, 1, 2, 1)
    child2 = Child(3, 2)
    young_couple_with_children = YoungCoupleWithChildren("Peterson", 600, 520, child1, child2)

    everland.add_room(young_couple)
    everland.add_room(young_couple_with_children)

    print(everland.get_monthly_consumptions())
    print(everland.pay())
    print(everland.status())
コード例 #5
0
ファイル: main.py プロジェクト: MiroVatov/Python-SoftUni
def test_one():
    young_couple = YoungCouple("Johnsons", 150, 205)
    # young_couple_but_broke = YoungCouple("Jacksons", 50, 55)
    child_one = Child(5, 1, 2, 1)
    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)
    # everland.add_room(young_couple_but_broke)
    # everland.add_room(young_couple)

    print(everland.get_monthly_consumptions())
    print(everland.pay())
    print(everland.status())
コード例 #6
0
    def test__calculate_expenses_when_1_consumer__expect_expenses_to_be_correct(
            self):
        consumers = [Child(1, 2, 3, 4)]
        self.room.calculate_expenses(consumers)

        self.assertEqual(consumers[0].get_monthly_expense(),
                         self.room.expenses)
コード例 #7
0
ファイル: test_room.py プロジェクト: mariatmv/PythonOOP
 def test_calculate_expenses(self):
     child = Child(20)
     room_one = Room('Ivanovi', 1500, 2)
     room_one.calculate_expenses(child)
     self.assertEqual(room_one.expenses, 600)
コード例 #8
0
ファイル: test_room.py プロジェクト: borislav777/SoftUni
 def test_calculate_expenses_with_children(self):
     fridge = [Fridge()]
     child = [Child(2, 1, 2, 3)]
     self.room.calculate_expenses(fridge, child)
     self.assertEqual(276, self.room.expenses)
コード例 #9
0
ファイル: main.py プロジェクト: LachezarKostov/SoftUni
    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()
コード例 #10
0
ファイル: test_room.py プロジェクト: MiroVatov/Python-SoftUni
 def test_room_calculate_expenses(self):
     appliances = [TV(), Laptop(), Fridge()] * self.room.members_count
     child1 = Child(5, 2, 3, 1)
     children = [child1]
     self.room.calculate_expenses(appliances, children)
     self.assertEqual(self.room.expenses, 552)
コード例 #11
0
ファイル: test_room.py プロジェクト: IlianDev/SoftUni-Courses
 def test_calculate_expenses(self):
     self.assertEqual(0, self.room.expenses)
     c1 = Child(5, 4, 1)
     expected = 300
     self.room.calculate_expenses([c1])
     self.assertEqual(expected, self.room.expenses)
コード例 #12
0
from typing import ClassVar, List

from project.appliances.appliance import Appliance
from project.appliances.tv import TV
from project.appliances.fridge import Fridge
from project.appliances.laptop import Laptop
from project.rooms.room import Room
from project.people.child import Child


class YoungCoupleWithChildren(Room):
    _adults_count: ClassVar[int] = 2
    _default_room_cost: ClassVar[int] = 30
    _default_appliances: ClassVar[List[Appliance]] = [TV(), Fridge(), Laptop()]

    def __init__(self, family_name: str, salary1: float, salary2: float,
                 *children: Child) -> None:
        members_count = self._adults_count + len(children)
        super().__init__(family_name, salary1 + salary2, members_count)
        self.children = list(children)
        self.appliances = self._default_appliances * members_count
        self.calculate_expenses(self.children, self.appliances)


yc = YoungCoupleWithChildren('Test', 1000, 1000, Child(5), Child(5))
print(yc.room_cost)
コード例 #13
0
    def test_calculate_expenses_when_1_consumer(self):
        child = [Child(10, 5, 6)]
        self.room.calculate_expenses(child)

        self.assertEqual(child[0].get_monthly_expense(), self.room.expenses)
コード例 #14
0
ファイル: main.py プロジェクト: Tarantulata/Portfolio
from project.everland import Everland
from project.people.child import Child
from project.rooms.young_couple import YoungCouple
from project.rooms.young_couple_with_children import YoungCoupleWithChildren

everland = Everland()

young_couple = YoungCouple("Johnsons", 150, 205)
child1 = Child(5, 1, 2, 1)
child2 = Child(3, 2)
young_couple_with_children = YoungCoupleWithChildren("Peterson", 600, 520,
                                                     child1, child2)

everland.add_room(young_couple)
everland.add_room(young_couple_with_children)

print(everland.get_monthly_consumptions())
print(everland.pay())
print(everland.status())
コード例 #15
0
ファイル: test_room.py プロジェクト: PetkoAndreev/Python-OOP
 def test_calculate_expenses__when_one_child_and_one_appliance__expect_to_calculate_them(self):
     consumers = [Child(5, 2, 2), TV()]
     self.room.calculate_expenses(consumers)
     expect = consumers[0].get_monthly_expense() + consumers[1].get_monthly_expense()
     self.assertEqual(expect, self.room.expenses)
コード例 #16
0
ファイル: test_room.py プロジェクト: PetkoAndreev/Python-OOP
 def test_calculate_expenses__when_one_child__expect_to_calculate_them(self):
     consumers = [Child(5, 2, 2)]
     self.room.calculate_expenses(consumers)
     self.assertEqual(consumers[0].get_monthly_expense(), self.room.expenses)