Skip to content

Instantly share code, notes, and snippets.

@BrianJoyce
Created October 8, 2012 18:49
Show Gist options
  • Save BrianJoyce/3854176 to your computer and use it in GitHub Desktop.
Save BrianJoyce/3854176 to your computer and use it in GitHub Desktop.
bowling game
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