diff --git a/LAB_OOP_10 b/LAB_OOP_10 new file mode 100644 index 0000000..e69de29 diff --git a/__pycache__/panda.cpython-312.pyc b/__pycache__/panda.cpython-312.pyc new file mode 100644 index 0000000..cf58104 Binary files /dev/null and b/__pycache__/panda.cpython-312.pyc differ diff --git a/main.py b/main.py new file mode 100644 index 0000000..76bdc22 --- /dev/null +++ b/main.py @@ -0,0 +1,23 @@ +from panda import Panda + +# Create 4 objects +panda1 = Panda("Po", 5, "Black & White", 100) +panda2 = Panda("Luna", 3, "Black & White", 80) +panda3 = Panda("Milo", 7, "Black & White", 120) +panda4 = Panda("Bella", 4, "Black & White", 90) + +# Print 1 attribute value +print(panda1.name) + +# Call methods on each object +panda1.eat() +panda1.sleep() + +panda2.eat() +panda2.sleep() + +panda3.eat() +panda3.sleep() + +panda4.eat() +panda4.sleep() \ No newline at end of file diff --git a/panda.py b/panda.py new file mode 100644 index 0000000..d63b096 --- /dev/null +++ b/panda.py @@ -0,0 +1,15 @@ +class Panda: + # Constructor + def __init__(self, name, age, color, weight): + self.name = name + self.age = age + self.color = color + self.weight = weight + + # Method 1 + def eat(self): + print(f"{self.name} is eating bamboo 🌿") + + # Method 2 + def sleep(self): + print(f"{self.name} is sleeping 😴") \ No newline at end of file