Skip to content

Commit

Permalink
Added Lab 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Sk4ine committed Feb 18, 2024
1 parent 6339027 commit 89825b5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
33 changes: 33 additions & 0 deletions python/src/lab6/cat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class Cat():
__age = 0
__name = ""
__breed = ""

def __init__(self, age, name, breed):
self.age = age
self.__name = name
self.__breed = breed

@property
def age(self) -> int:
return self.__age

@age.setter
def age(self, age):
assert (age >= 0 and age <= 25), "Invalid age"
self.__age = age

@property
def breed(self) -> str:
return self.__breed

@property
def name(self) -> str:
return self.__name

@name.setter
def name(self, name):
self.__name = name

def petTheCat(self):
print("Cat {0} says meow\n".format(self.__name))
21 changes: 16 additions & 5 deletions python/src/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
def summ(a: int, b: int) -> int:
return a + b

from lab6 import cat

if __name__ == "__main__":
print("Hello world")
print(summ(3, 4))
cat1 = cat.Cat(6, "Tiger", "Siamese")
cat2 = cat.Cat(9, "No name", "unknown")

cat1.age = 3

cat2.name = "Marshal"
cat1.name = "Luna"

print("Cat's age is {0}".format(cat1.age))
print("Its name is {0}".format(cat1.name))
cat1.petTheCat()

print("Another cat's age is {0}".format(cat2.age))
print("Its breed is {0}".format(cat2.breed))
cat2.petTheCat()

0 comments on commit 89825b5

Please sign in to comment.