1
1
#!/usr/bin/env python
2
+ import math
2
3
3
4
4
5
class Wheel (object ):
@@ -10,17 +11,20 @@ def __init__(self, rim, tyre):
10
11
def diameter (self ):
11
12
return self .rim + (self .tyre * 2 )
12
13
14
+ def circumference (self ):
15
+ return self .diameter () * math .pi
16
+
13
17
14
18
def wheelify (data ):
15
19
return [Wheel (cell [0 ], cell [1 ]) for cell in data ]
16
20
17
21
18
22
class Gear (object ):
19
23
20
- def __init__ (self , chainring , cog , rim , tyre ):
24
+ def __init__ (self , chainring , cog , wheel = None ):
21
25
self .chainring = chainring
22
26
self .cog = cog
23
- self .wheel = Wheel ( rim , tyre )
27
+ self .wheel = wheel
24
28
25
29
def ratio (self ):
26
30
return self .chainring / float (self .cog )
@@ -35,14 +39,17 @@ def __init__(self, data):
35
39
self .wheels = wheelify (data )
36
40
37
41
def diameters (self ):
38
- return [self .diameter (wheel ) for wheel in self .wheels ]
39
-
40
- def diameter (self , wheel ):
41
- return wheel .rim + (wheel .tyre * 2 )
42
+ return [wheel .diameter () for wheel in self .wheels ]
42
43
43
44
44
- print Gear (52 , 11 , 26 , 1.5 ).gear_inches ()
45
- print Gear (52 , 11 , 24 , 1.25 ).gear_inches ()
45
+ print Gear (52 , 11 , Wheel ( 26 , 1.5 ) ).gear_inches ()
46
+ print Gear (52 , 11 , Wheel ( 24 , 1.25 ) ).gear_inches ()
46
47
47
48
data = [[622 , 20 ], [622 , 23 ], [559 , 30 ], [559 , 40 ]]
48
49
print RevealingReferences (data ).diameters ()
50
+
51
+ wheel = Wheel (26 , 1.5 )
52
+ print wheel .circumference ()
53
+
54
+ print Gear (52 , 11 , wheel ).gear_inches ()
55
+ print Gear (52 , 11 ).ratio ()
0 commit comments