-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
46 lines (37 loc) · 1.56 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import math
class SkidPointCalculator:
def __init__(self, chain_ring: int, cog: int) -> None:
self.chain_ring = chain_ring
self.cog = cog
def calculate_lcm(self) -> int:
return math.lcm(self.chain_ring, self.cog)
def calculate_num_skid_points(self) -> float | int:
return round(self.calculate_lcm() / self.chain_ring, 2)
def calculate_gear_ratio(self) -> float | int:
return round(self.chain_ring / self.cog, 2)
def calculate_skid_point(self) -> tuple[float | int, float | int]:
return self.calculate_gear_ratio(), self.calculate_num_skid_points()
# チェーンリングの歯の数の入力
while True:
try:
chain_ring: int = int(input('チェーンリングの歯の数を入力してください。: '))
break
except ValueError:
print('-----------------------')
print('⚠️ 数値を入力してください。')
print('-----------------------')
# コグの歯の数の入力
while True:
try:
cog: int = int(input('コグの歯の数を入力してください。: '))
break
except ValueError:
print('-----------------------')
print('⚠️ 数値を入力してください。')
print('-----------------------')
calculator = SkidPointCalculator(chain_ring, cog)
# 出力
print('-----------------------')
print('ギア比:', calculator.calculate_gear_ratio())
print('スキッドポイント数:', calculator.calculate_num_skid_points())
print('-----------------------')