Skip to content

Commit 76a541a

Browse files
committed
[refactor] Extract as sample code
1 parent 568fda4 commit 76a541a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class HitPoint:
2+
MIN: Final[int] = 0
3+
MAX: Final[int] = 999
4+
5+
def __init__(self, value: int) -> None:
6+
if value < self.MIN:
7+
raise ValueError(f"{self.MIN}以上を指定してください")
8+
if value > self.MAX:
9+
raise ValueError(f"{self.MAX}以下を指定してください")
10+
11+
self.value = value
12+
13+
def damage(self, damage_amount: int) -> HitPoint:
14+
"""ダメージを受ける"""
15+
16+
def recover(self, recovery_amount: int) -> HitPoint:
17+
"""回復する"""

0 commit comments

Comments
 (0)