Created
October 8, 2012 18:49
-
-
Save BrianJoyce/3854176 to your computer and use it in GitHub Desktop.
bowling game
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'pry' | |
| class BowlingGame | |
| attr_accessor :max_pins_available, :roll_score, :frame_scores | |
| def initialize | |
| @game = [] | |
| @frame_scores = [] | |
| end | |
| def frame | |
| @max_pins_available = 10 | |
| @roll_score = 0 | |
| 2.times {@frame_scores << roll} | |
| end | |
| def roll | |
| @roll_score = 10 - rand(@max_pins_available +1) | |
| @max_pins_available = @max_pins_available - @roll_score | |
| @roll_score | |
| end | |
| def game | |
| 10.times {frame} | |
| end | |
| end | |
| brian_game = BowlingGame.new | |
| brian_game.game | |
| puts brian_game.frame_scores.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment