Skip to content

Commit 44847e4

Browse files
committed
Added Inheritance - Lab
1 parent 0bdff9f commit 44847e4

File tree

24 files changed

+111
-0
lines changed

24 files changed

+111
-0
lines changed
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Food:
2+
3+
def __init__(self, expiration_date):
4+
self.expiration_date = str(expiration_date)
5+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from project.food import Food
2+
3+
4+
class Fruit(Food):
5+
6+
def __init__(self, name, expiration_date):
7+
self.name = str(name)
8+
self.expiration_date = str(expiration_date)
9+
Binary file not shown.

OOP/3.Inheritance/Inheritance - Lab/02. Single Inheritance/project/__init__.py

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Animal:
2+
3+
def eat(self):
4+
return "eating..."
5+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from project.animal import Animal
2+
3+
4+
class Dog(Animal):
5+
6+
def bark(self):
7+
return "barking..."
8+
Binary file not shown.

OOP/3.Inheritance/Inheritance - Lab/03. Multiple Inheritance/project/__init__.py

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from project.person import Person
2+
3+
4+
class Employee(Person):
5+
6+
def get_fired(self):
7+
return "fired..."
8+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Person:
2+
3+
def sleep(self):
4+
return "sleeping..."
5+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from project.person import Person
2+
from project.employee import Employee
3+
4+
5+
class Teacher(Employee, Person):
6+
7+
def teach(self):
8+
return "teaching..."
9+
Binary file not shown.

OOP/3.Inheritance/Inheritance - Lab/04. Multilevel Inheritance/project/__init__.py

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from project.vehicle import Vehicle
2+
3+
4+
class Car(Vehicle):
5+
6+
def drive(self):
7+
return "driving..."
8+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from project.car import Car
2+
3+
4+
class SportsCar(Car):
5+
6+
def race(self):
7+
return "racing..."
8+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Vehicle:
2+
3+
def move(self):
4+
return "moving..."
5+
Binary file not shown.

OOP/3.Inheritance/Inheritance - Lab/05. Hierarchical Inheritance/project/__init__.py

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Animal:
2+
3+
def eat(self):
4+
return "eating..."
5+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from project.animal import Animal
2+
3+
4+
class Cat(Animal):
5+
6+
def meow(self):
7+
return "meowing..."
8+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from project.animal import Animal
2+
3+
4+
class Dog(Animal):
5+
6+
def bark(self):
7+
return "barking..."
8+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Stack:
2+
3+
def __init__(self):
4+
self.data = []
5+
6+
def push(self, element):
7+
self.data.append(element)
8+
9+
def pop(self):
10+
return self.data.pop()
11+
12+
def top(self):
13+
return self.data[-1]
14+
15+
def is_empty(self):
16+
return False if self.data else True
17+
18+
def __str__(self):
19+
return '[' + ', '.join(self.data[::-1]) + ']'
20+

0 commit comments

Comments
 (0)