From 2265799043ff8297e67ec32b0f9b32a6a62fa3ec Mon Sep 17 00:00:00 2001
From: Pavel
Date: Thu, 10 Mar 2022 14:57:02 +0300
Subject: [PATCH 01/15] Seems to be completed.
---
Lesson_6/task_1.py | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 Lesson_6/task_1.py
diff --git a/Lesson_6/task_1.py b/Lesson_6/task_1.py
new file mode 100644
index 0000000..9fe476c
--- /dev/null
+++ b/Lesson_6/task_1.py
@@ -0,0 +1,31 @@
+# Создать класс TrafficLight (светофор).
+# Определить у него один атрибут color (цвет) и метод running (запуск);
+# атрибут реализовать как приватный;
+# в рамках метода реализовать переключение светофора в режимы: красный, жёлтый, зелёный;
+# продолжительность первого состояния (красный) составляет 7 секунд,
+# второго (жёлтый) — 2 секунды, третьего (зелёный) — на ваше усмотрение;
+# переключение между режимами должно осуществляться только в указанном порядке (красный, жёлтый, зелёный);
+# проверить работу примера, создав экземпляр и вызвав описанный метод.
+
+import time
+
+
+class TrafficLights:
+ # __color = None
+ __colors = ['RED', 'YELLOW', 'GREEN']
+
+ def running(self):
+ i = 0
+ while i < 3:
+ print(f'Traffic light color is: {TrafficLights.__colors[i]}')
+ if i == 0:
+ time.sleep(7)
+ elif i == 1:
+ time.sleep(2)
+ else:
+ time.sleep(5)
+ i += 1
+
+
+traffic = TrafficLights()
+traffic.running()
From b70f7580a5137427c66e65ba23e3241b88b29ce2 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Thu, 10 Mar 2022 16:17:17 +0300
Subject: [PATCH 02/15] in progress...
---
Lesson_6/task_2.py | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
create mode 100644 Lesson_6/task_2.py
diff --git a/Lesson_6/task_2.py b/Lesson_6/task_2.py
new file mode 100644
index 0000000..082b224
--- /dev/null
+++ b/Lesson_6/task_2.py
@@ -0,0 +1,26 @@
+# Реализовать класс Road (дорога).
+# определить атрибуты: length (длина), width (ширина);
+# значения атрибутов должны передаваться при создании экземпляра класса;
+# атрибуты сделать защищёнными;
+# определить метод расчёта массы асфальта, необходимого для покрытия всей дороги;
+# использовать формулу: длина*ширина*масса асфальта для покрытия одного кв. метра дороги
+# асфальтом, толщиной в 1 см*число см толщины полотна;
+# проверить работу метода.
+# Например: 20 м*5000 м*25 кг*5 см = 12500 т.
+
+class Road:
+ # _length = None
+ # _width = None
+ # weigth = None
+ # tickness = None
+
+ def __init__(self, _length, _width):
+ self._length = _length
+ self._width = _width
+
+ def weigth(self):
+ return self._length * self._width
+
+
+r = Road(100, 20)
+print(r. weigth())
From 0a39483eaf33d6d9e1d83ed174e09ec0a608d6d3 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Thu, 10 Mar 2022 16:51:00 +0300
Subject: [PATCH 03/15] Completed.
---
Lesson_6/task_2.py | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/Lesson_6/task_2.py b/Lesson_6/task_2.py
index 082b224..45feb86 100644
--- a/Lesson_6/task_2.py
+++ b/Lesson_6/task_2.py
@@ -9,18 +9,21 @@
# Например: 20 м*5000 м*25 кг*5 см = 12500 т.
class Road:
- # _length = None
- # _width = None
- # weigth = None
- # tickness = None
def __init__(self, _length, _width):
self._length = _length
self._width = _width
- def weigth(self):
- return self._length * self._width
+ def square(self):
+ square = self._length * self._width / 1000000
+ print(f'Road surface area is: {square} km\u00B2')
+ def mass(self, mass_m2=25, tickness=25):
+ mass = self._length * self._width * mass_m2 * tickness / 1000
+ print(f'For the construction of a road with length of {self._length} m. and width of {self._width} m.,\n'
+ f' {mass} tons of asphalt will be required.')
-r = Road(100, 20)
-print(r. weigth())
+
+road = Road(15000, 20)
+road.square()
+road.mass()
From f5a9636646f6089274caef64dd7ef99e39f5ffb8 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Thu, 10 Mar 2022 16:59:43 +0300
Subject: [PATCH 04/15] In progress...
---
Lesson_6/task_3.py | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
create mode 100644 Lesson_6/task_3.py
diff --git a/Lesson_6/task_3.py b/Lesson_6/task_3.py
new file mode 100644
index 0000000..f69e928
--- /dev/null
+++ b/Lesson_6/task_3.py
@@ -0,0 +1,26 @@
+# Реализовать базовый класс Worker (работник).
+# определить атрибуты: name, surname, position (должность), income (доход);
+# последний атрибут должен быть защищённым и ссылаться на словарь,
+# содержащий элементы: оклад и премия, например, {"wage": wage, "bonus": bonus};
+# создать класс Position (должность) на базе класса Worker;
+# в классе Position реализовать методы получения полного имени сотрудника (get_full_name)
+# и дохода с учётом премии (get_total_income);
+# проверить работу примера на реальных данных: создать экземпляры класса Position,
+# передать данные, проверить значения атрибутов, вызвать методы экземпляров.
+
+class Worker:
+
+ def __init__(self, name, surname, position, wage, bonus):
+ self.name = name
+ self.surname = surname
+ self.position = position
+ self._income = {'wage': wage, 'bonus': bonus}
+
+
+class Position(Worker):
+
+ def get_total_name(self):
+ pass
+
+ def get_total_income(self):
+ pass
From 8e83a75030448a0135ef67ea74776b0ae621afa5 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Thu, 10 Mar 2022 21:07:21 +0300
Subject: [PATCH 05/15] Still in progress...
---
Lesson_6/task_3.py | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/Lesson_6/task_3.py b/Lesson_6/task_3.py
index f69e928..99f603d 100644
--- a/Lesson_6/task_3.py
+++ b/Lesson_6/task_3.py
@@ -10,17 +10,25 @@
class Worker:
- def __init__(self, name, surname, position, wage, bonus):
+ def __init__(self, name, surname, position, salary, bonus):
self.name = name
self.surname = surname
self.position = position
- self._income = {'wage': wage, 'bonus': bonus}
+ self._income = {'salary': salary, 'bonus': bonus}
class Position(Worker):
+ def __init__(self, name, surname, position, salary, bonus):
+ super().__init__(name, surname, position, salary, bonus)
- def get_total_name(self):
- pass
+ def get_full_name(self):
+ return self.name + ' ' + self.surname + ' ' + self.position
def get_total_income(self):
- pass
+ # self.__income = {'salary': salary, 'bonus': bonus}
+ return self._income.get('salary') + self._income.get('bonus')
+
+
+val = Position('James', 'Bond', 'Agent', 200000, 120000)
+print(val.get_full_name())
+print(val.get_total_income())
From 3f85aa7aa1427a0ec7c8a5c64d2c99a56b7c323d Mon Sep 17 00:00:00 2001
From: Pavel
Date: Thu, 10 Mar 2022 21:18:27 +0300
Subject: [PATCH 06/15] Complete.
---
Lesson_6/task_3.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/Lesson_6/task_3.py b/Lesson_6/task_3.py
index 99f603d..74415cc 100644
--- a/Lesson_6/task_3.py
+++ b/Lesson_6/task_3.py
@@ -14,21 +14,21 @@ def __init__(self, name, surname, position, salary, bonus):
self.name = name
self.surname = surname
self.position = position
- self._income = {'salary': salary, 'bonus': bonus}
+ self.salary = salary
+ self.bonus = bonus
class Position(Worker):
- def __init__(self, name, surname, position, salary, bonus):
- super().__init__(name, surname, position, salary, bonus)
def get_full_name(self):
- return self.name + ' ' + self.surname + ' ' + self.position
+ return self.name + ' ' + self.surname
def get_total_income(self):
- # self.__income = {'salary': salary, 'bonus': bonus}
- return self._income.get('salary') + self._income.get('bonus')
+ self._income = {'salary': self.salary, 'bonus': self.bonus}
+ return self.salary + self.bonus
-val = Position('James', 'Bond', 'Agent', 200000, 120000)
+val = Position('James', 'Bond', 'Agent', 300000, 140000)
+print(val.position)
print(val.get_full_name())
print(val.get_total_income())
From ed623f4be8a61b1556baec45662799be647dcc27 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Thu, 10 Mar 2022 21:28:56 +0300
Subject: [PATCH 07/15] In progress...
---
Lesson_6/task_4.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
create mode 100644 Lesson_6/task_4.py
diff --git a/Lesson_6/task_4.py b/Lesson_6/task_4.py
new file mode 100644
index 0000000..3bb14b2
--- /dev/null
+++ b/Lesson_6/task_4.py
@@ -0,0 +1,51 @@
+# Реализуйте базовый класс Car.
+# у класса должны быть следующие атрибуты: speed, color, name, is_police (булево).
+# А также методы: go, stop, turn(direction), которые должны сообщать,
+# что машина поехала, остановилась, повернула (куда);
+# опишите несколько дочерних классов: TownCar, SportCar, WorkCar, PoliceCar;
+# добавьте в базовый класс метод show_speed, который должен показывать
+# текущую скорость автомобиля; для классов TownCar и WorkCar переопределите
+# метод show_speed. При значении скорости свыше 60 (TownCar) и 40 (WorkCar)
+# должно выводиться сообщение о превышении скорости.
+# Создайте экземпляры классов, передайте значения атрибутов.
+# Выполните доступ к атрибутам, выведите результат.
+# Вызовите методы и покажите результат.
+
+class Car:
+
+ def __init__(self, speed, color, name, is_police):
+ self.speed = speed
+ self.color = color
+ self.name = name
+ self.is_police = bool(is_police)
+
+ def go(self)
+ pass
+
+ def stop(self):
+ pass
+
+ def turn(self):
+ pass
+
+
+class TownCar(Car):
+
+ def towncar(self):
+ pass
+
+class SportCar(Car):
+
+ def sportcar(self):
+ pass
+
+class WorkCar(Car):
+
+ def workcar(self):
+ pass
+
+
+class PoliceCar(Car):
+
+ def policecar(self):
+ pass
From 012dd467498291f61a8ecdedfae29fb78be460b6 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Fri, 11 Mar 2022 12:21:44 +0300
Subject: [PATCH 08/15] Completed.
---
Lesson_6/task_4.py | 67 +++++++++++++++++++++++++++++++++++-----------
1 file changed, 52 insertions(+), 15 deletions(-)
diff --git a/Lesson_6/task_4.py b/Lesson_6/task_4.py
index 3bb14b2..ef5bccd 100644
--- a/Lesson_6/task_4.py
+++ b/Lesson_6/task_4.py
@@ -13,39 +13,76 @@
class Car:
- def __init__(self, speed, color, name, is_police):
- self.speed = speed
- self.color = color
+ def __init__(self, name, color, speed, is_police):
self.name = name
+ self.color = color
+ self.speed = speed
self.is_police = bool(is_police)
- def go(self)
- pass
+ def go(self):
+ return f'start moving with the speed {self.speed} km/h'
def stop(self):
- pass
+ return f'slowdown and stop moving'
- def turn(self):
- pass
+ def turn_left(self):
+ return f'turn left'
+
+ def turn_right(self):
+ return f'turn right'
+
+ def show_speed(self):
+ return f'Current car speed is: {self.speed}'
class TownCar(Car):
- def towncar(self):
- pass
+ def __init__(self, name, color, speed, is_police):
+ super().__init__(name, color, speed, is_police)
+
+ def town_car(self):
+ if self.speed > 60:
+ print('Exceeding the speed limit for moving around the city in 60 km/h. Current speed of', self.name, 'is',
+ self.speed, 'km/h')
+ else:
+ print('No over-speed detected. The current speed of', self.name, 'is', self.speed, 'km/h')
+
class SportCar(Car):
- def sportcar(self):
+ def sport_car(self):
pass
+
class WorkCar(Car):
- def workcar(self):
- pass
+ def work_car(self):
+ if self.speed > 40:
+ print('Exceeding the speed limit for special vehicles for moving around the city in 40 km/h. '
+ 'Current speed of', self.name, 'is', self.speed, 'km/h')
+ else:
+ print('No over-speed detected. The current speed of', self.name, 'is', self.speed, 'km/h')
class PoliceCar(Car):
- def policecar(self):
- pass
+ def police_car(self):
+ if self.is_police == True:
+ print('This', self.name, 'belongs to the police office')
+ else:
+ print('This', self.name, 'is civilian')
+
+
+car_a = TownCar('Mercedes', 'White', 60, False)
+car_b = SportCar('McLaren', 'Dark-red', 240, False)
+car_c = WorkCar('Kamaz', 'Orange', 60, False)
+car_d = PoliceCar('BMW', 'Unknown', 100, True)
+print(f'Car {car_a.name} {car_a.go()} then {car_a.turn_left()}, {car_a.stop()}')
+print(f'Car {car_b.name} {car_b.go()} then {car_b.turn_right()}, {car_b.stop()}')
+print(f'Car {car_c.name} {car_c.go()} then {car_c.turn_left()}, {car_c.stop()}')
+print(f'Car {car_d.name} {car_d.go()} then {car_d.turn_left()}, {car_d.stop()}')
+car_a.town_car()
+car_b.sport_car()
+car_c.work_car()
+car_d.police_car()
+print(f'Is {car_a.name} belong to police office?: {car_a.is_police}')
From db317bbb1ebe2a5e9dc89631f72d503c4ad5dfb0 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Fri, 11 Mar 2022 12:34:14 +0300
Subject: [PATCH 09/15] In the process...
---
Lesson_6/task_5.py | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 Lesson_6/task_5.py
diff --git a/Lesson_6/task_5.py b/Lesson_6/task_5.py
new file mode 100644
index 0000000..585d029
--- /dev/null
+++ b/Lesson_6/task_5.py
@@ -0,0 +1,30 @@
+# Реализовать класс Stationery (канцелярская принадлежность).
+# определить в нём атрибут title (название) и метод draw (отрисовка). Метод выводит сообщение «Запуск отрисовки»;
+# создать три дочерних класса Pen (ручка), Pencil (карандаш), Handle (маркер);
+# в каждом классе реализовать переопределение метода draw.
+# Для каждого класса метод должен выводить уникальное сообщение;
+# создать экземпляры классов и проверить, что выведет описанный метод для каждого экземпляра.
+
+class Stationary:
+ def __init__(self, title):
+ self.title = title
+
+ def draw(self):
+ print('Start the rendering process.')
+
+
+class Pen(Stationary):
+ pass
+
+
+class Pencil(Stationary):
+ pass
+
+
+class Handle(Stationary):
+ pass
+
+
+a = Stationary("Beginning")
+a.draw()
+print(a.draw())
From edca707cc659a037c47e82958de4095eadfa304a Mon Sep 17 00:00:00 2001
From: Pavel
Date: Fri, 11 Mar 2022 13:26:39 +0300
Subject: [PATCH 10/15] slightly edited. Completed.
---
Lesson_6/task_4.py | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/Lesson_6/task_4.py b/Lesson_6/task_4.py
index ef5bccd..1439403 100644
--- a/Lesson_6/task_4.py
+++ b/Lesson_6/task_4.py
@@ -40,7 +40,7 @@ class TownCar(Car):
def __init__(self, name, color, speed, is_police):
super().__init__(name, color, speed, is_police)
- def town_car(self):
+ def show_speed(self):
if self.speed > 60:
print('Exceeding the speed limit for moving around the city in 60 km/h. Current speed of', self.name, 'is',
self.speed, 'km/h')
@@ -50,13 +50,19 @@ def town_car(self):
class SportCar(Car):
+ def __init__(self, name, color, speed, is_police):
+ super().__init__(name, color, speed, is_police)
+
def sport_car(self):
pass
class WorkCar(Car):
- def work_car(self):
+ def __init__(self, name, color, speed, is_police):
+ super().__init__(name, color, speed, is_police)
+
+ def show_speed(self):
if self.speed > 40:
print('Exceeding the speed limit for special vehicles for moving around the city in 40 km/h. '
'Current speed of', self.name, 'is', self.speed, 'km/h')
@@ -66,7 +72,10 @@ def work_car(self):
class PoliceCar(Car):
- def police_car(self):
+ def __init__(self, name, color, speed, is_police):
+ super().__init__(name, color, speed, is_police)
+
+ def police(self):
if self.is_police == True:
print('This', self.name, 'belongs to the police office')
else:
@@ -81,8 +90,8 @@ def police_car(self):
print(f'Car {car_b.name} {car_b.go()} then {car_b.turn_right()}, {car_b.stop()}')
print(f'Car {car_c.name} {car_c.go()} then {car_c.turn_left()}, {car_c.stop()}')
print(f'Car {car_d.name} {car_d.go()} then {car_d.turn_left()}, {car_d.stop()}')
-car_a.town_car()
+car_a.show_speed()
car_b.sport_car()
-car_c.work_car()
-car_d.police_car()
+car_c.show_speed()
+car_d.police()
print(f'Is {car_a.name} belong to police office?: {car_a.is_police}')
From 668bc785f53362fe68f8443d1c85a376f693ca30 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Fri, 11 Mar 2022 13:50:21 +0300
Subject: [PATCH 11/15] Almost completed...
---
Lesson_6/task_5.py | 41 +++++++++++++++++++++++++++++++++--------
1 file changed, 33 insertions(+), 8 deletions(-)
diff --git a/Lesson_6/task_5.py b/Lesson_6/task_5.py
index 585d029..b07f4e0 100644
--- a/Lesson_6/task_5.py
+++ b/Lesson_6/task_5.py
@@ -6,25 +6,50 @@
# создать экземпляры классов и проверить, что выведет описанный метод для каждого экземпляра.
class Stationary:
- def __init__(self, title):
+ def __init__(self, title, pen, pencil, handle):
self.title = title
+ self.pen = bool(pen)
+ self.pencil = bool(pencil)
+ self.handle = bool(handle)
def draw(self):
- print('Start the rendering process.')
+ print('Start the rendering process: ', self.title)
class Pen(Stationary):
- pass
+ # def __init__(self, title, pen, pencil, handle):
+ # super().__init__(title, pen, pencil, handle)
+
+ def draw(self):
+ if self.pen == True:
+ print('Pen drawing started')
+ else:
+ print('Pen is not available')
class Pencil(Stationary):
- pass
+ def draw(self):
+
+ if self.pencil == True:
+ print('Pencil drawing started')
+ else:
+ print('Pencil is not available')
class Handle(Stationary):
- pass
+ def draw(self):
+
+ if self.handle == True:
+ print('Handle drawing started')
+ else:
+ print('Handle is not available')
-a = Stationary("Beginning")
-a.draw()
-print(a.draw())
+title = Stationary('Beginning', False, False, False)
+pen = Pen('Beginning', True, False, False)
+pencil = Pencil('Beginning', False, True, False)
+handle = Handle('Beginning', False, False, True)
+title.draw()
+pen.draw()
+pencil.draw()
+handle.draw()
From 2398cf1f5fb7b89591c5e6daf46584690d68472d Mon Sep 17 00:00:00 2001
From: Pavel
Date: Fri, 11 Mar 2022 14:44:17 +0300
Subject: [PATCH 12/15] Completed.
---
Lesson_6/task_5.py | 39 ++++++++++++++++++++++++++++++---------
1 file changed, 30 insertions(+), 9 deletions(-)
diff --git a/Lesson_6/task_5.py b/Lesson_6/task_5.py
index b07f4e0..53425b3 100644
--- a/Lesson_6/task_5.py
+++ b/Lesson_6/task_5.py
@@ -8,9 +8,9 @@
class Stationary:
def __init__(self, title, pen, pencil, handle):
self.title = title
- self.pen = bool(pen)
- self.pencil = bool(pencil)
- self.handle = bool(handle)
+ self.pen = pen
+ self.pencil = pencil
+ self.handle = handle
def draw(self):
print('Start the rendering process: ', self.title)
@@ -22,29 +22,30 @@ class Pen(Stationary):
def draw(self):
if self.pen == True:
- print('Pen drawing started')
+ print('The pen tool is ready. The rendering process is started')
else:
- print('Pen is not available')
+ print('The pen tool is not available. Please, choose a different tool.')
class Pencil(Stationary):
def draw(self):
if self.pencil == True:
- print('Pencil drawing started')
+ print('The pencil tool is ready. The rendering process is started')
else:
- print('Pencil is not available')
+ print('The pencil tool is not available. Please, choose a different tool.')
class Handle(Stationary):
def draw(self):
if self.handle == True:
- print('Handle drawing started')
+ print('The handle tool is ready. The rendering process is started')
else:
- print('Handle is not available')
+ print('The handle tool is not available. Please, choose a different tool.')
+print('Test option 1:')
title = Stationary('Beginning', False, False, False)
pen = Pen('Beginning', True, False, False)
pencil = Pencil('Beginning', False, True, False)
@@ -53,3 +54,23 @@ def draw(self):
pen.draw()
pencil.draw()
handle.draw()
+
+print('Test option 2:')
+title = Stationary('Beginning', False, False, False)
+pen = Pen('Beginning', True, False, False)
+pencil = Pencil('Beginning', True, False, False)
+handle = Handle('Beginning', False, False, False)
+title.draw()
+pen.draw()
+pencil.draw()
+handle.draw()
+
+print('Test option 3:')
+title = Stationary('Beginning', False, False, False)
+pen = Pen('Beginning', False, False, False)
+pencil = Pencil('Beginning', False, True, False)
+handle = Handle('Beginning', True, False, False)
+title.draw()
+pen.draw()
+pencil.draw()
+handle.draw()
From 6ad5a897fd9fda8599afc82ca084f44ea94a8fbc Mon Sep 17 00:00:00 2001
From: Pavel
Date: Fri, 11 Mar 2022 14:46:14 +0300
Subject: [PATCH 13/15] Slightly modified. Completed.
---
Lesson_6/task_4.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Lesson_6/task_4.py b/Lesson_6/task_4.py
index 1439403..79ba9de 100644
--- a/Lesson_6/task_4.py
+++ b/Lesson_6/task_4.py
@@ -17,7 +17,7 @@ def __init__(self, name, color, speed, is_police):
self.name = name
self.color = color
self.speed = speed
- self.is_police = bool(is_police)
+ self.is_police = is_police
def go(self):
return f'start moving with the speed {self.speed} km/h'
@@ -76,7 +76,7 @@ def __init__(self, name, color, speed, is_police):
super().__init__(name, color, speed, is_police)
def police(self):
- if self.is_police == True:
+ if self.is_police:
print('This', self.name, 'belongs to the police office')
else:
print('This', self.name, 'is civilian')
From 7a0256c079b4dc4b72863a58e7345f1fb948b812 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Fri, 11 Mar 2022 14:48:04 +0300
Subject: [PATCH 14/15] Slightly modified. Completed.
---
Lesson_6/task_4.py | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/Lesson_6/task_4.py b/Lesson_6/task_4.py
index 79ba9de..83f0c49 100644
--- a/Lesson_6/task_4.py
+++ b/Lesson_6/task_4.py
@@ -37,9 +37,6 @@ def show_speed(self):
class TownCar(Car):
- def __init__(self, name, color, speed, is_police):
- super().__init__(name, color, speed, is_police)
-
def show_speed(self):
if self.speed > 60:
print('Exceeding the speed limit for moving around the city in 60 km/h. Current speed of', self.name, 'is',
@@ -50,18 +47,12 @@ def show_speed(self):
class SportCar(Car):
- def __init__(self, name, color, speed, is_police):
- super().__init__(name, color, speed, is_police)
-
def sport_car(self):
pass
class WorkCar(Car):
- def __init__(self, name, color, speed, is_police):
- super().__init__(name, color, speed, is_police)
-
def show_speed(self):
if self.speed > 40:
print('Exceeding the speed limit for special vehicles for moving around the city in 40 km/h. '
@@ -72,9 +63,6 @@ def show_speed(self):
class PoliceCar(Car):
- def __init__(self, name, color, speed, is_police):
- super().__init__(name, color, speed, is_police)
-
def police(self):
if self.is_police:
print('This', self.name, 'belongs to the police office')
From c7b2ff1103f00f3d467df37c104e5d354df54a29 Mon Sep 17 00:00:00 2001
From: Pavel
Date: Fri, 11 Mar 2022 14:48:52 +0300
Subject: [PATCH 15/15] Slightly modified. Completed.
---
Lesson_6/task_5.py | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/Lesson_6/task_5.py b/Lesson_6/task_5.py
index 53425b3..698e8a1 100644
--- a/Lesson_6/task_5.py
+++ b/Lesson_6/task_5.py
@@ -6,6 +6,7 @@
# создать экземпляры классов и проверить, что выведет описанный метод для каждого экземпляра.
class Stationary:
+
def __init__(self, title, pen, pencil, handle):
self.title = title
self.pen = pen
@@ -17,8 +18,6 @@ def draw(self):
class Pen(Stationary):
- # def __init__(self, title, pen, pencil, handle):
- # super().__init__(title, pen, pencil, handle)
def draw(self):
if self.pen == True:
@@ -28,8 +27,8 @@ def draw(self):
class Pencil(Stationary):
- def draw(self):
+ def draw(self):
if self.pencil == True:
print('The pencil tool is ready. The rendering process is started')
else:
@@ -37,8 +36,8 @@ def draw(self):
class Handle(Stationary):
- def draw(self):
+ def draw(self):
if self.handle == True:
print('The handle tool is ready. The rendering process is started')
else: