From 02c2a89e1b33bc8e5485cb73b651d7b97312515e Mon Sep 17 00:00:00 2001 From: kokter Date: Wed, 28 Feb 2024 22:00:05 +0300 Subject: [PATCH] lab 5 python Tselikov --- python/src/__init__.py | 31 +++++++++++++++++++++++++++++++ python/src/main.py | 12 +++++++----- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/python/src/__init__.py b/python/src/__init__.py index e69de29..f2e6c04 100644 --- a/python/src/__init__.py +++ b/python/src/__init__.py @@ -0,0 +1,31 @@ +class Cat: + + def __init__(self, age, breed, name): + self.name = name + self.age = 0 + self.breed = breed + self.set_age(age) + + def set_age(self, new_age): + if new_age < 0: + print("Возраст не может быть меньше 0") + else: + self.age = new_age + + def set_breed(self, new_breed): + self.breed = new_breed + + def set_name(self, new_name): + self.name = new_name + + def get_name(self): + return self.name + + def get_breed(self): + return self.breed + + def get_age(self): + return self.age + + def print_info_cat(self): + print("------------------------------", "\nCat's name is", self.get_name(), "\nCat's breed is", self.get_breed(), "\nCat's age is", self.get_age()) diff --git a/python/src/main.py b/python/src/main.py index e37a77c..41f178e 100644 --- a/python/src/main.py +++ b/python/src/main.py @@ -1,7 +1,9 @@ -def summ(a: int, b: int) -> int: - return a + b - +from __init__ import Cat if __name__ == "__main__": - print("Hello world") - print(summ(3, 4)) + cat1 = Cat(14, "Siamese", "Alice") + Cat.print_info_cat(cat1) + cat2 = Cat(2, "British", "Oleg") + cat3 = Cat(25, "Street", "Anton") + Cat.print_info_cat(cat2) + Cat.print_info_cat(cat3)