Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lab 5 python Tselikov #46

Open
wants to merge 1 commit into
base: Tselikov_Aleksej_Aleksandrovich
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions python/src/__init__.py
Original file line number Diff line number Diff line change
@@ -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())
12 changes: 7 additions & 5 deletions python/src/main.py
Original file line number Diff line number Diff line change
@@ -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)