__main__.py

10 января 2024, 14:01
import random class Person:       def __init__(self, name, gender, age=0, health=100, occupation="Безработная"):             self.name = name             self.gender = gender             self.age = age             self.health = health             self.occupation = occupation             self.sex_partner = None             self.needs = {                   'food': 100,                   'entertainment': 100,                   'sleep': 100,                   'music': 100             }       def perform_daily_activity(self):             activities = [                   self.cook,                   self.clean_up,                   self.engage_in_sex,                   self.manicure,                   self.read_daria_doncova,                   self.sleep,                   self.go_to_club,                   self.watch_tv,                   self.listen_to_music,             ]             random_activity = random.choice(activities)             random_activity()       def cook(self):             print(f"{self.name} готовит.")             self.needs['food'] -= random.randint(5, 15)       def clean_up(self):             print(f"{self.name} убирается.")             self.needs['entertainment'] += random.randint(5, 15)       def engage_in_sex(self):             if self.sex_partner is not None:                   print(f"{self.name} занимается сексом с {self.sex_partner}.")                   self.needs['entertainment'] += random.randint(10, 20)             else:                   print(f"{self.name} не занимается сексом сегодня.")       def manicure(self):             print(f"{self.name} делает маникюр.")             self.needs['entertainment'] += random.randint(5, 10)       def read_daria_doncova(self):             print(f"{self.name} читает книгу Дарьи Донцовой.")             self.needs['entertainment'] += random.randint(5, 15)       def sleep(self):             print(f"{self.name} идет спать.")             self.needs['sleep'] = 100       def go_to_club(self):             print(f"{self.name} идет в клуб.")             self.needs['entertainment'] += random.randint(10, 25)       def watch_tv(self):             print(f"{self.name} смотрит телевизор.")             self.needs['entertainment'] += random.randint(5, 20)       def listen_to_music(self):             if self.sex_partner is not None:                   print(f"{self.name} слушает музыку на Spotify.")             else:                   print(f"{self.name} слушает музыку на Yandex Music.")             self.needs['music'] -= random.randint(10, 30)       def print_daily_summary(self):             print(f"\nИтоги дня для {self.name}:")             for need, value in self.needs.items():                   print(f"{need.capitalize()}: {value}%") # Класс для девушки, наследуемый от класса Person class Girl(Person):       def __init__(self, name, age=0, health=100, occupation="Безработная"):             super().__init__(name, gender="женский", age=age, health=health, occupation=occupation)       def find_sex_partner(self):             potential_partners = ["Партнер 1", "Партнер 2", "Партнер 3"]             self.sex_partner = random.choice(potential_partners) # Генерация случайных параметров для девушки random_age = random.randint(18, 30) random_health = random.randint(80, 100) # Моделирование 24 часов girl = Girl(name="Алиса", age=random_age, health=random_health) for hour in range(24):       print(f"\n----- Час {hour + 1} -----")       girl.perform_daily_activity()       if hour == 0:             girl.find_sex_partner() # Вывод итогов дня после 24 часов girl.print_daily_summary()

Пока нет комментариев. Авторизуйтесь, чтобы оставить свой отзыв первым!