Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
c187ff5
setup rspec
May 21, 2023
9dd35ce
created first test for frame class
May 21, 2023
510882b
passed firat test
May 21, 2023
2eb8f0a
removed rolls method
May 21, 2023
522361f
test written for checking spares
May 21, 2023
d488b23
passed spare test
May 21, 2023
10579be
method for checking strike added
May 21, 2023
86b792b
added pins down attribute
May 21, 2023
d39e097
added pins doown attr
May 21, 2023
918b473
scoring basic frame test driven
May 21, 2023
13dc0ad
added test for valid roll input
May 21, 2023
d055849
added test for spare score
May 21, 2023
56d41ce
spare score only updates when new roll been added
May 21, 2023
b494ada
removed return statements
May 21, 2023
c203179
test driven scoring a strike
May 21, 2023
deda096
test for adding strike bonus when next frame a strike passed
May 21, 2023
5ab733c
strike bonus handled when next roll alo a strike
May 21, 2023
92caf49
add spare followed by strike check
May 21, 2023
9477358
added test for 3 strikes in a row
May 21, 2023
880b133
added tests for tenth frame with 3 rolls
May 21, 2023
711eedf
created the BowlingGame class
May 21, 2023
b5d8f33
added test for adding frames
May 21, 2023
8067be1
add frames test passed
May 21, 2023
7c7950d
calculates total score for 0 frame
May 21, 2023
9bdb6f4
added test for gutter game
May 21, 2023
0a9e581
named test context better
May 21, 2023
7cd2a4f
passed total score test for single frame
May 21, 2023
92bac38
passed test for finding total with 2 frames
May 21, 2023
8902148
added test for 10 frames
May 21, 2023
3e58eb8
does not update total score if added frame is a spare
May 21, 2023
a05e58d
changed structure of total_score method
May 21, 2023
c23086b
passing tests for total score with spares spares
May 21, 2023
2bdc660
passes the total with spares and refactored
May 21, 2023
d23e091
added another test for strike calculation
May 21, 2023
de62e04
another test for strike condition
May 21, 2023
3de5f9a
test added for spare on last frame
May 21, 2023
078503d
refactored current score method
May 21, 2023
e39bf6a
test driven strike behavior when start with strike
May 21, 2023
f6eef57
updated README
May 21, 2023
5a29de9
added test for one strike in middle
May 21, 2023
129c81b
passed test for 5 strike game
May 21, 2023
f0830f0
passed all strike game test
May 21, 2023
d043633
refactored
May 21, 2023
d678eb1
require_relative in bowling_game.rb added
May 21, 2023
1b70acf
added index to running total
May 21, 2023
1fea97d
passes final teat
May 21, 2023
4f54ae1
refactored strike bonus method
May 22, 2023
b3f6514
added helper function
May 22, 2023
594969c
using helper method in test suite to simulate games
May 22, 2023
14bb55f
merged test cleanup into main
May 22, 2023
573907a
refactoring score method
May 22, 2023
4d419e3
removing frames pins_down attribute
May 22, 2023
c1ac043
removing comments
May 22, 2023
d4b2ef6
removing running a game in bowling_game.rb
May 22, 2023
9007eb8
updating README
May 22, 2023
b1f1cfe
refactoring add_strike_bonus
May 22, 2023
a739c06
removed simulation of game in the bowling_game file
May 22, 2023
2c01da3
removing redundant or statement in total_up_to(i)
May 22, 2023
50e8919
removing initial total_up_to for emepty game
May 22, 2023
6b7bdc6
refactored score_sum method
May 22, 2023
a33f892
neatening up update_score method
May 22, 2023
4b95603
checking if score == nil in update_score method
May 22, 2023
885f14a
refactoring continues
May 22, 2023
c4df492
removed require from spec helper
May 22, 2023
dda4fdd
bowling_game_spec into integration folder
May 22, 2023
5255850
adding comments to bowling_game
May 22, 2023
d89c4c6
Merge branch 'main' into refactor
lplclaremont May 22, 2023
4535690
Merge pull request #1 from lplclaremont/refactor
lplclaremont May 22, 2023
141798b
removing redundant :score attr_reader in frame class
May 22, 2023
268f4b5
removing branches
May 22, 2023
25037b2
added feedback branch
May 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

source "https://rubygems.org"

# gem "rails"

gem "rspec", "~> 3.12"
26 changes: 26 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.5.0)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)

PLATFORMS
arm64-darwin-21

DEPENDENCIES
rspec (~> 3.12)

BUNDLED WITH
2.4.13
63 changes: 3 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,8 @@
Bowling Challenge in Ruby
=================

* Feel free to use google, your notes, books, etc. but work on your own
* If you refer to the solution of another coach or student, please put a link to that in your README
* If you have a partial solution, **still check in a partial solution**
* You must submit a pull request to this repo with your code by 9am Monday week
## Outline

## The Task
This is a ruby program which handles the calculation of a bowling game for one player. It is based on regular bowling rules and is designed to find the running total after each frame is played (to be inputted by the user).

**THIS IS NOT A BOWLING GAME, IT IS A BOWLING SCORECARD PROGRAM. DO NOT GENERATE RANDOM ROLLS. THE USER INPUTS THE ROLLS.**

Count and sum the scores of a bowling game for one player. For this challenge, you do _not_ need to build a web app with a UI, instead, just focus on the logic for bowling (you also don't need a database). Next end-of-unit challenge, you will have the chance to translate the logic to Javascript and build a user interface.

A bowling game consists of 10 frames in which the player tries to knock down the 10 pins. In every frame the player can roll one or two times. The actual number depends on strikes and spares. The score of a frame is the number of knocked down pins plus bonuses for strikes and spares. After every frame the 10 pins are reset.

As usual please start by

* Forking this repo

* Finally submit a pull request before Monday week at 9am with your solution or partial solution. However much or little amount of code you wrote please please please submit a pull request before Monday week at 9am.

___STRONG HINT, IGNORE AT YOUR PERIL:___ Bowling is a deceptively complex game. Careful thought and thorough diagramming — both before and throughout — will save you literal hours of your life.

## Focus for this challenge
The focus for this challenge is to write high-quality code.

In order to do this, you may pay particular attention to the following:
* Using diagramming to plan your approach to the challenge
* TDD your code
* Focus on testing behaviour rather than state
* Commit often, with good commit messages
* Single Responsibility Principle and encapsulation
* Clear and readable code

## Bowling — how does it work?

### Strikes

The player has a strike if he knocks down all 10 pins with the first roll in a frame. The frame ends immediately (since there are no pins left for a second roll). The bonus for that frame is the number of pins knocked down by the next two rolls. That would be the next frame, unless the player rolls another strike.

### Spares

The player has a spare if the knocks down all 10 pins with the two rolls of a frame. The bonus for that frame is the number of pins knocked down by the next roll (first roll of next frame).

### 10th frame

If the player rolls a strike or spare in the 10th frame they can roll the additional balls for the bonus. But they can never roll more than 3 balls in the 10th frame. The additional rolls only count for the bonus not for the regular frame count.

10, 10, 10 in the 10th frame gives 30 points (10 points for the regular first strike and 20 points for the bonus).
1, 9, 10 in the 10th frame gives 20 points (10 points for the regular spare and 10 points for the bonus).

### Gutter Game

A Gutter Game is when the player never hits a pin (20 zero scores).

### Perfect Game

A Perfect Game is when the player rolls 12 strikes (10 regular strikes and 2 strikes for the bonus in the 10th frame). The Perfect Game scores 300 points.

In the image below you can find some score examples.

More about ten pin bowling here: http://en.wikipedia.org/wiki/Ten-pin_bowling

![Ten Pin Score Example](images/example_ten_pin_scoring.png)
In my tests, when refering to a 'simple frame', I mean a frame in which the player has not rolled a spare or a strike.
5 changes: 5 additions & 0 deletions coverage/.last_run.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"result": {
"line": 100.0
}
}
Loading