-
Notifications
You must be signed in to change notification settings - Fork 0
sprint-2 #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
sprint-2 #8
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| #1 Задание | ||
|
|
||
| class Case: | ||
|
|
||
| def __init__(self, test_case_id, name, step_description, expected_result): | ||
| self.test_case_id = test_case_id | ||
| self.name = name | ||
| self.step_description = step_description | ||
| self.expected_result = expected_result | ||
|
|
||
| def print_test_case_info(self): | ||
| print(f"ID тест-кейса: {self.test_case_id}" | ||
| f"\nНазвание: {self.name}" | ||
| f"\nОписание шага: {self.step_description}" | ||
| f"\nОжидаемый результат: {self.expected_result}") | ||
|
|
||
| class ExtendedCase(Case): | ||
|
|
||
| def __init__(self, test_case_id, name, step_description, expected_result, precondition, environment): | ||
| self.precondition = precondition | ||
| self.environment = environment | ||
| super().__init__(test_case_id, name, step_description, expected_result) | ||
|
|
||
| def print_test_case_info(self): | ||
| print(f"ID тест-кейса: {self.test_case_id}" | ||
| f"\nНазвание: {self.name}" | ||
| f"\nОписание шага: {self.step_description}" | ||
| f"\nОжидаемый результат: {self.expected_result}" | ||
| f"\nПредусловие: {self.precondition}" | ||
| f"\nОкружение: {self.environment}") | ||
|
|
||
| case = ExtendedCase('1', 'Наличие кнопки Принять', '1. Открыть вкладку приёма документов 2. Проверить наличие кнопки ', | ||
| 'Кнопка доступна', 'Открыть сервис', 'Яндекс Браузер') | ||
| case.print_test_case_info() | ||
|
|
||
|
|
||
| #2 Задание | ||
|
|
||
| class Movies: | ||
|
|
||
| def __init__(self): | ||
| self.movies = [] | ||
|
|
||
| def add_movie(self, movie): | ||
| self.movies.append(movie) | ||
|
|
||
| class Comedy(Movies): | ||
|
|
||
| def add_movie(self, movie): | ||
| sself.movies.append(movie) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: опечатка в слове self
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: здесь и далее: добавление фильма в конец списка уже реализовано в родительском классе. Чтобы не дублировать код можно вызвать метод add_movie у класса родителя через super(). |
||
| return f'Комедии: {self.movies}' | ||
|
|
||
| class Drama(): | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: не реализовано наследование |
||
|
|
||
| def add_movie(self, movie): | ||
| self.movies.append(movie) | ||
| return f'Драмы: {self.movies}' | ||
|
|
||
|
|
||
| print(Comedy().add_movie('Большой куш')) | ||
| print(Drama().add_movie('Оружейный барон')) | ||
|
|
||
|
|
||
| #3 Задание | ||
|
|
||
| class PointsForPlace: | ||
|
|
||
| @staticmethod | ||
| def get_points_for_place(place): | ||
| points = 0 | ||
| if place > 100: | ||
| print('Баллы начисляются только первым 100 участникам') | ||
| elif place < 1: | ||
| print('Спортсмен не может занять нулевое или отрицательное место') | ||
| else: | ||
| points = 100 - place | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: неверная формула расчета баллов |
||
| return points | ||
|
|
||
| class PointsForMeters: | ||
|
|
||
| @staticmethod | ||
| def get_points_for_meters(meters): | ||
| points = 0 | ||
| if meters < 0: | ||
| print('Количество метров не может быть отрицательным') | ||
| else: | ||
| points = meters * 0.5 | ||
| return points | ||
|
|
||
| class TotalPoints(PointsForPlace, PointsForMeters): | ||
|
|
||
| @staticmethod | ||
| def get_total_points(meters, place): | ||
| total = PointsForPlace.get_points_for_place(place) + PointsForMeters.get_points_for_meters(meters) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: класс TotalPoints наследует методы get_points_for_place и get_points_for_meters. Обращение через будет более целесообразным. Иначе наследование не имеет смысла. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Тут стоило указать варианты обращения через self или super |
||
| return total | ||
|
|
||
| points_for_place = PointsForPlace() | ||
| print(points_for_place.get_points_for_place(10)) | ||
| points_for_meters = PointsForMeters() | ||
| print(points_for_meters.get_points_for_meters(10)) | ||
| total_points = TotalPoints() | ||
| print(total_points.get_points_for_place(10)) | ||
| print(total_points.get_points_for_meters(10)) | ||
| print(total_points.get_total_points(100, 10)) | ||
|
|
||
| #4 Задание | ||
|
|
||
| class EmployeeSalary: | ||
|
|
||
| def __init__(self, name, hours, rest_days, email): | ||
| self.name = name | ||
| self.hours = hours | ||
| self.rest_days = rest_days | ||
| self.email = email | ||
| self.hourly_payment = 400 | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: атрибут hourly_payment относится к экземпляру класса, а должен к классу. |
||
|
|
||
| @classmethod | ||
| def get_hours(cls, name, hours, rest_days, email): | ||
| if hours is None: | ||
| hours = (7 - rest_days) * 8 | ||
| return cls(name, hours, rest_days, email) | ||
|
|
||
| @classmethod | ||
| def get_email(cls, name, hours, rest_days, email): | ||
| if email is None: | ||
| email = f'{name}@email.com' | ||
| return cls(name, hours, rest_days, email) | ||
|
|
||
| def set_hourly_payment(self): | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: set_hourly_payment должен быть классовым методом. Иначе изменение будет происходить в рамках конкретного экземпляра класса, а не класса в целом. |
||
| self.hourly_payment = 500 | ||
|
|
||
| def salary(self, hours): | ||
| return hours * EmployeeSalary.hourly_payment | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: для расчета не нужно передавать методу количество часов. Метод должен брать их от экземпляра класса.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Можно лучше: доступ к атрибуту hourly_payment можно получить через экземпляр класса. |
||
|
|
||
|
|
||
| #5 Задание | ||
|
|
||
| class Results: | ||
|
|
||
| def __init__(self, victories, draws, losses): | ||
| self.victories = victories | ||
| self.draws = draws | ||
| self.losses = losses | ||
|
|
||
| class Football(): | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: не реализовано наследование от Results |
||
|
|
||
| def __init__(self, victories, draws, losses): | ||
| super().__init__(victories, draws, losses) | ||
|
|
||
| def number_of_wins(self): | ||
| return f'Футбольных побед: {self.victories}' | ||
|
|
||
| def number_of_draws(self): | ||
| return f'Футбольных ничьих: {self.draws}' | ||
|
|
||
| def number_of_losses(self): | ||
| return f'Футбольных поражений: {self.losses}' | ||
|
|
||
| def total_points(self): | ||
| return f'Общее количество очков: {3 * self.victories + self.draws}' | ||
|
|
||
|
|
||
| class Hockey(): | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: не реализовано наследование от Results |
||
|
|
||
| def __init__(self, victories, draws, losses): | ||
| super().__init__(victories, draws, losses) | ||
|
|
||
| def number_of_wins(self): | ||
| return f'Хоккейных побед: {self.victories}' | ||
|
|
||
| def number_of_draws(self): | ||
| return f'Хоккейных ничьих: {self.draws}' | ||
|
|
||
| def number_of_losses(self): | ||
| return f'Хоккейных поражений: {self.losses}' | ||
|
|
||
| def total_points(self): | ||
| return f'Общее количество очков: {3 * self.victories + self.draws}' | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нужно исправить: неверная формула расчета очков |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нужно исправить: первые четыре параметра уже умеет печатать родительский класс в методе print_test_case_info. Вызвать его можно через функцию super().