| Total Complexity | 4 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # noinspection PyPackages |
||
| 2 | from ..illustrations.illustration import Illustration # type: ignore |
||
| 3 | |||
| 4 | # noinspection PyPackages |
||
| 5 | from ..quiz_element import QuizElement # type: ignore |
||
| 6 | |||
| 7 | # noinspection PyPackages |
||
| 8 | from ..illustrations.state_of_illustrations import StateOfIllustrations # type: ignore |
||
| 9 | |||
| 10 | |||
| 11 | class Answer(QuizElement): |
||
| 12 | def __init__( |
||
| 13 | self, text: str, correct: bool, illustration: Illustration | None = None |
||
| 14 | ) -> None: |
||
| 15 | super().__init__(text, illustration) |
||
| 16 | |||
| 17 | assert isinstance(correct, bool) |
||
| 18 | self.correct = correct |
||
| 19 | |||
| 20 | def __hash__(self) -> int: |
||
| 21 | object_hash = hash(frozenset((self.text, self.correct, self.illustration))) |
||
| 22 | return object_hash |
||
| 23 | |||
| 24 | def __eq__(self, other: object) -> bool: |
||
| 25 | if not isinstance(other, Answer): |
||
| 26 | return False |
||
| 27 | return ( |
||
| 28 | self.text == other.text |
||
| 29 | and self.correct == other.correct |
||
| 30 | and self.illustration == other.illustration |
||
| 31 | ) |
||
| 32 |