diff --git a/python/src/cat.py b/python/src/cat.py new file mode 100644 index 0000000..16b0c2e --- /dev/null +++ b/python/src/cat.py @@ -0,0 +1,25 @@ +class Cat: + def __init__(self, age, name, color): + if age >= 19: + raise ValueError("This age is not correctly specified") + self.age = age + self.name = name + self.color = color + + def set_age(self, age): + if age >= 19: + raise ValueError("This age is not correctly specified") + else: + self.age = age + + def set_name(self, name): + self.name = name + + def get_age(self): + return self.age + + def get_name(self): + return self.name + + def get_color(self): + return self.color \ No newline at end of file diff --git a/python/src/main.py b/python/src/main.py index e37a77c..411b7a5 100644 --- a/python/src/main.py +++ b/python/src/main.py @@ -1,7 +1,15 @@ -def summ(a: int, b: int) -> int: - return a + b +from cat import Cat if __name__ == "__main__": - print("Hello world") - print(summ(3, 4)) + print('lab 5(python)') + cat = Cat(3, "Jack", "black and white") + cat.set_age(5) + cat.set_name("Tom") + cat2 = Cat(5, "Tom", "white") + + print(f"Возраст кота - {cat.get_age()}") + print(f"Его имя - {cat.get_name()}") + print(f"Его цвет - {cat.get_color()}") + +