Skip to content

Conversation

@sofo4ka
Copy link
Owner

@sofo4ka sofo4ka commented Jan 19, 2021

No description provided.



class TrafficLight:
__color = [('красный', 7), ('желтый', 2), ('зеленый', 6)]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а ещё можно юзать словарть)

for element in self.__color:
if element[0] not in colors:
print('Некорректные цвета')
elif self.__color[0][0] != colors[0] or self.__color[1][0] != colors[1] or self.__color[2][0] != colors[2]:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно запихнуть логику по временным пределам горения светофора в словарь) Это будет удобнее, загляни в разбор!)
А ещё это позволит избавиться от копипасты кода и if-ов.

self._length = length
self._width = width

def mass_calculation(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

давай тут добавим параметр толщины и будем прокидывать его в функцию, как просят в условии


def __init__(self, name, surname, position, income):
super().__init__(name, surname, position, income)
self._full_income_value = self._income.get('wage') + self._income.get('bonus')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это лучше вынести в проперти или в отдельный метод


class TownCar(Car):
def __init__(self, name, speed, color, is_police):
super().__init__(name, speed, color, is_police)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Смотри, у тебя тут и в аналогичных случаях поведение родительского метода никак не переопределяется.
Ты не дописываешь новых полей и не изменяешь значения старых.
То есть поведение никак не меняется, поэтому смысла переопределять этот метод нет.

super().__init__(name, speed, color, is_police)

def show_speed(self):
if self.speed <= 60:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ограничение скорости тут и в остальных классах можно убрать в поле самого класса)


if __name__ == '__main__':
t = TownCar(speed=48, color='green', name='УАЗ-3303', is_police=False)
s = SportCar(speed=180, color='red', name='Ferrari 488', is_police=False)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пора учиться писать тесты) - https://www.youtube.com/watch?v=1HtEPEn4-LY&t=306s&ab_channel=Luchanos


class Pen(Stationery):
def __init__(self, title):
super().__init__(title)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут то же что и выше - нет необходимости переопределять

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants