bowling_score_keeper 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89bb212b1994a2e242e3bf78bcf211796a321f59
4
- data.tar.gz: 460e5feef2e61fd1b5810e4c6715bd076080a872
3
+ metadata.gz: 649ff8adb62941a64912e661116d89d50d9d14fc
4
+ data.tar.gz: d07402b03135b22eefe1ef957636a626f0f38620
5
5
  SHA512:
6
- metadata.gz: 8a0c17810eb8faf470cb7372f6e54dc490463a05c27027126248c63ce69e00fb40ee8d81f3fd122a73c00da826e30b4478f0dc367c18f86dcfe0ba7de93b0c8c
7
- data.tar.gz: 032621c1828114b089540884edcfd5d6dda6e94f73f55a94d61c7ca6aad132f25383ad140babd13b1cf8d6d46386c260f9a2d6a01b5153044fcaf6c9b974ad5c
6
+ metadata.gz: be018618899c5ce374dbddb6db399dbdedd06f03c8da6341fca8048573323f973c811f61665a2ca62d1bafcc5260e6a9686a055f3fe9a9a777038686030ab5b8
7
+ data.tar.gz: 93dea91428889314a8bf25f994efd2e6558f91bb4214482ee0564c7991c5264fc361259f14de8f1108473ffb61cf85034186b91ae95d2a762da730a3963ddc4f
data/README.md CHANGED
@@ -8,9 +8,16 @@ Basic implementation of a bowling game score keeper.
8
8
 
9
9
  ## Usage
10
10
 
11
- Start the gem from the command line with:
11
+ Start the gem from the command line with:
12
+
12
13
  $ bowling_score_keeper
13
14
 
15
+ or
16
+
17
+ $ bsk
18
+
19
+ and follow the on-screen instructions.
20
+
14
21
 
15
22
  ## Development
16
23
 
data/bin/bsk ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bowling_score_keeper'
4
+
5
+ game = BowlingScoreKeeper.new
6
+ game.call
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  f.match(%r{^(test|spec|features)/})
20
20
  end
21
21
  spec.bindir = "bin"
22
- spec.executables = ["bowling_score_keeper"]
22
+ spec.executables = ["bowling_score_keeper", "bsk"]
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.15"
@@ -21,31 +21,37 @@ class BowlingScoreKeeper
21
21
  end
22
22
 
23
23
  def score
24
- return score_for_too_few_rolls if too_few_rolls
25
-
26
- score = 0
27
- first_in_frame = 0
28
-
29
- 10.times do
30
- if(strike?(first_in_frame))
31
- score += MAX_ROLL_POINTS +
32
- @rolls[first_in_frame + 1] +
33
- @rolls[first_in_frame + 2]
34
- first_in_frame += 1
35
- elsif(spare?(first_in_frame))
36
- score += MAX_ROLL_POINTS + @rolls[first_in_frame + 2]
37
- first_in_frame += 2
38
- else
39
- score += @rolls[first_in_frame] + @rolls[first_in_frame + 1]
40
- first_in_frame += 2
24
+ begin
25
+ score = 0
26
+ first_in_frame = 0
27
+
28
+ 10.times do
29
+ if(strike?(first_in_frame))
30
+ score += MAX_ROLL_POINTS +
31
+ @rolls[first_in_frame + 1] +
32
+ @rolls[first_in_frame + 2]
33
+ first_in_frame += 1
34
+ elsif(spare?(first_in_frame))
35
+ score += MAX_ROLL_POINTS + @rolls[first_in_frame + 2]
36
+ first_in_frame += 2
37
+ else
38
+ score += @rolls[first_in_frame] + @rolls[first_in_frame + 1]
39
+ first_in_frame += 2
40
+ end
41
41
  end
42
- end
43
42
 
44
- score
43
+ score
44
+ rescue
45
+ 'incomplete'
46
+ end
45
47
  end
46
48
 
47
49
  private
48
50
 
51
+ def print_score
52
+ puts "Your score is #{score}"
53
+ end
54
+
49
55
  def set_name
50
56
  @name = ''
51
57
  while @name.empty?
@@ -63,7 +69,7 @@ class BowlingScoreKeeper
63
69
 
64
70
  case @value
65
71
  when 'score'
66
- puts "Your score is #{score}"
72
+ print_score
67
73
  when 'exit'
68
74
  print "Congratulation #{@name},"
69
75
  puts "You finished the game with a score of: #{score}"
@@ -84,12 +90,4 @@ class BowlingScoreKeeper
84
90
  def strike?(first_in_frame)
85
91
  @rolls[first_in_frame] == MAX_ROLL_POINTS
86
92
  end
87
-
88
- def too_few_rolls
89
- @rolls.size <= 3
90
- end
91
-
92
- def score_for_too_few_rolls
93
- @rolls.inject(0) { |s, e| s + e }
94
- end
95
93
  end
@@ -1 +1 @@
1
- VERSION = "0.2.0"
1
+ VERSION = "0.2.1"
data/todo.txt CHANGED
@@ -1,3 +1,2 @@
1
1
  Multiple players mode
2
2
  Fancy output (ASCII graphic)
3
- Make it a CLI tool
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bowling_score_keeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mugur (Bud) Chirica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-17 00:00:00.000000000 Z
11
+ date: 2017-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,6 +85,7 @@ email:
85
85
  - chirica.mugurel@gmail.com
86
86
  executables:
87
87
  - bowling_score_keeper
88
+ - bsk
88
89
  extensions: []
89
90
  extra_rdoc_files: []
90
91
  files:
@@ -98,6 +99,7 @@ files:
98
99
  - README.md
99
100
  - Rakefile
100
101
  - bin/bowling_score_keeper
102
+ - bin/bsk
101
103
  - bin/console
102
104
  - bin/setup
103
105
  - bowling_score_keeper.gemspec