I began building the Dice Game at the end of the Ruby Koans sequence. It's an extra credit project, but it turned out to be a very helpful exercise in helping me to work through a more complicated project than any I had encountered before. The game built off of previous work in the Koans sequence, specifically a scoring project and defining a dice class.
This command line game allows you to choose how many players, enter the players' names, and then it rolls five dice for each player and determines the winner based on a separate scoring rubric.
The most challenging part of this app was adding the option for more than two players. It was relatively easy to return the highest number in the array, match the score to the appropriate name, and announce the winner. However, finding and announcing a tie was much more difficult. I was psyched when I finally got the tie announcement to work.
Here's the code.
No comments:
Post a Comment