Passed
Push — main ( 853695...d18ab9 )
by Máté
03:41 queued 02:14
created

answer.Answer.__eq__()   A

Complexity

Conditions 2

Size

Total Lines 7
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nop 2
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