回答編集履歴

1

マジックナンバーの消去

2021/06/18 16:58

投稿

ppaul
ppaul

スコア24666

test CHANGED
@@ -6,9 +6,13 @@
6
6
 
7
7
  class Aggregate(dict):
8
8
 
9
- def __init__(self):
9
+ def __init__(self, maxcount=100, endcode='9999'):
10
10
 
11
11
  self.count = 0
12
+
13
+ self.maxcount = maxcount
14
+
15
+ self.endcode = endcode
12
16
 
13
17
 
14
18
 
@@ -16,7 +20,7 @@
16
20
 
17
21
  code, sales = s.split()
18
22
 
19
- if code == '9999':
23
+ if code == self.maxcount:
20
24
 
21
25
  return False
22
26
 
@@ -30,7 +34,7 @@
30
34
 
31
35
  self.count += 1
32
36
 
33
- return self.count < 100
37
+ return self.count < self.maxcount
34
38
 
35
39
 
36
40