diff --git a/gb-python-ls6-1.py b/gb-python-ls6-1.py new file mode 100644 index 0000000..6df064d --- /dev/null +++ b/gb-python-ls6-1.py @@ -0,0 +1,19 @@ +import time + + +class TrafficLight: + + def running(self): + while True: + self.__color = "red" + print(f"{self.__color}") + time.sleep(7) + self.__color = "yellow" + print(f"{self.__color}") + time.sleep(2) + self.__color = "green" + print(f"{self.__color}") + time.sleep(7) + +t = TrafficLight() +t.running() \ No newline at end of file diff --git a/gb-python-ls6-2.py b/gb-python-ls6-2.py new file mode 100644 index 0000000..3ba5e29 --- /dev/null +++ b/gb-python-ls6-2.py @@ -0,0 +1,12 @@ + +class Road: + def __init__(self, length, width): + self._length = length + self._width = width + + def mass_calculation(self, weight=25, thickness=5): + return f'Asphalt mass: {(self._length * self._width * weight * thickness) / 1000} tons' + + +road = Road(5000, 20) +print(road.mass_calculation()) \ No newline at end of file diff --git a/gb-python-ls6-3.py b/gb-python-ls6-3.py new file mode 100644 index 0000000..aa7532c --- /dev/null +++ b/gb-python-ls6-3.py @@ -0,0 +1,19 @@ +class Worker: + def __init__(self, name, surname, position, wage, bonus): + self.name = name + self.surname = surname + self.position = position + self._income = {"profit": wage, "bonus": bonus} + + +class Position(Worker): + def get_full_name(self): + return f"{self.name} {self.surname}" + + def get_full_profit(self): + return f"{sum(self._income.values())}" + +manager = Position("Micky", "Mouse", "CEO", 200000, 25000) +print(manager.get_full_name()) +print(manager.position) +print(manager.get_full_profit()) diff --git a/gb-python-ls6-5.py b/gb-python-ls6-5.py new file mode 100644 index 0000000..72110d7 --- /dev/null +++ b/gb-python-ls6-5.py @@ -0,0 +1,31 @@ +class Stationery: + def __init__(self, title="Something that can draw"): + self.title = title + + def draw(self): + print(f"Just start drawing! {self.title}") + + +class Pen(Stationery): + def draw(self): + print(f"Start write with {self.title} pen!") + + +class Pencil(Stationery): + def draw(self): + print(f"Start decorate with {self.title} pencil!") + + +class Marker(Stationery): + def draw(self): + print(f"Start highlight with {self.title} marker!") + + +stat = Stationery() +stat.draw() +pen = Pen("Big") +pen.draw() +pencil = Pencil("Faber-Castell") +pencil.draw() +marker = Marker("Erich Krause") +marker.draw() \ No newline at end of file