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

answer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 20
dl 0
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A Answer.__init__() 0 7 1
A Answer.__eq__() 0 7 2
A Answer.__hash__() 0 3 1
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