class ChildTest(unittest.TestCase): def setUp(self): self.sweet_home = House() self.dasha = Child(name='Даша', house=self.sweet_home) def test_sleep(self): self.dasha.fullness = 30 self.dasha.happiness = 100 self.dasha.sleep() self.assertEqual(self.dasha.fullness, 20) self.assertEqual(self.dasha.happiness, 100) def test_act_full_up(self): self.dasha.fullness = 30 self.dasha.happiness = 100 self.dasha.act() self.assertEqual(self.dasha.fullness, 20) self.assertEqual(self.dasha.happiness, 100) def test_act_hungry(self): self.dasha.fullness = 10 self.dasha.act() self.assertEqual(self.dasha.fullness, 20)
masha.act() kolya.act() for kitty in kitties: kitty.act() if serge.state == "dead" or masha.state == "dead" or kolya.state == "dead": count_death += 1 break return count_kitty home = House() serge = Husband(name='Сережа') serge.go_to_the_house(house=home) masha = Wife(name='Маша') masha.go_to_the_house(house=home) kolya = Child(name='Коля') kolya.go_to_the_house(house=home) for food_incidents, money_incidents in itertools.product(range(6), range(6)): cprint( f"Эксперимент с пропаданием половина еды {food_incidents} раз, " f"пропаданием половины денег {money_incidents} раз", color="blue") for salary in range(50, 401, 50): home.new_experiment() serge.new_experiment() masha.new_experiment() kolya.new_experiment() cprint(f"с зарплатой {salary}", color="yellow") max_cats = simulation(money_incident=money_incidents, food_incident=food_incidents,
SUE = Person(["Sue"], [], Person.FEMALE) ROBERT = Person(["Robert"], [], Person.MALE) ANNA = Person(["Anna"], [], Person.FEMALE) HANNAH = Person(["Hannah"], [], Person.FEMALE) SAVANNAH = Person(["Savannah"], [], Person.FEMALE) KEN = Person(["Ken Torse"], ["Ken"], Person.MALE) JANE = Person(["Jane"], [], Person.FEMALE) JOSEPH = Person(["Joseph"], [], Person.MALE) JAKE = Person(["Jake"], [], Person.MALE) JAMES = Person(["James"], [], Person.MALE) FAMILY = [ Sibling(JOHN, JOSEPH), Sibling(JOHN, JAKE), Sibling(JOHN, JAMES), Sibling(JOHN, JANE), Parent(ANNE, JOHN), Parent(PETE, JOHN), Sibling(PETE, ANNA), Sibling(PETE, HANNAH), Sibling(PETE, SAVANNAH), Spouse(SAVANNAH, KEN), Child(ROBERT, SAVANNAH), Child(ROBERT, KEN), Parent(BOB, ANNE), Parent(SUE, ANNE) ] if __name__ == '__main__': for r in FAMILY: print r
def setUp(self): self.sweet_home = House() self.dasha = Child(name='Даша', house=self.sweet_home)