Skip to content

jeffreycastro/bowling-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Bowling game script

To use:

Sample usage:

ruby run_game.rb [[6,2],[9,1],[1,8],[10],[4,1],[5,2],[0,3],[10],[7,0],[10,7,2]]
ruby run_game.rb [[10],[10],[10],[10],[10],[10],[10],[10],[10],[10,10,10]]

sample output:

[8, 18, 27, 42, 47, 54, 57, 74, 81, 100]


Rules/Assumptions:

  • Game can only have 10 frames
  • A frame is invalid if (you can try the commands included):
    1. It is empty
    ruby run_game.rb [[],[],[],[],[],[],[],[],[],[]]
    
    1. It has invalid number of inputs for Strike/Non-Strike frames
    ruby run_game.rb [[6],[9,1],[1,8],[10],[4,1],[5,2],[0,3],[10],[7,0],[10,7,2]]  
    ruby run_game.rb [[10,7,2],[9,1],[1,8],[10],[4,1],[5,2],[0,3],[10],[7,0],[10,7,2]]
    ruby run_game.rb [[6,2],[9,1],[1,8],[10],[4,1],[5,2],[0,3],[10],[7,0],[1,1,1]]  
    ruby run_game.rb [[6,2],[9,1],[1,8],[10],[4,1],[5,2],[0,3],[10],[7,0],[10]]
    
    1. It has more than 2 values inside for frames 1-9
    ruby run_game.rb [[1,1,1],[2,2,2],[3,3,3],[4,4,4],[4,1],[5,2],[0,3],[10],[7,0],[10,7,2]]
    
    1. It has more than 3 values inside for all frames
    ruby run_game.rb [[1,1,1,1],[2,2,2,2],[3,3,3],[4,4,4],[4,1],[5,2],[0,3],[10],[7,0],[10,10,10,10]]
    
    1. It has values inside that are either negative, or more than 10
    ruby run_game.rb [[-6,2],[9,11],[11,8],[10],[4,1],[5,2],[0,3],[10],[7,0],[10,7,2]]
    
    1. It has values inside that total to more than 10 for frames 1-9
    ruby run_game.rb [[6,5],[9,1],[1,8],[10],[4,1],[5,2],[0,3],[10],[7,0],[10,10,10]]
    

About

Simple bowling game ruby script

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages