Skip to content

jnappy/secret_number

 
 

Repository files navigation

First, fork this repository and run:

cd ~/Sites/
git clone https://github.com/your-username-here/secret_number.git

Next, open sublime text and paste the following code into a new file. Save the file as ~/Sites/secret_number/your_name_here/secret_number.rb:

###############################################################################
#
# We're ready to program! To practice our Ruby skills lets create a secret
# number game. In this game players have three tries to guess a secret number
# between 1 and 10.
#
# Here are some guidelines to building your game:
#
#   Intros
#   - Welcome the player to your game. Let them know who created the game.
#   - Ask for the player's name then personally greet them by printing to the
#     screen, "Hi player_name!"
#   - Any good game will communicate the rules. Let the player know they must
#     guess a number between 1 and 10 and that they only have 3 tries to do so.
#
#   Functionality:
#     - Manually specify the secret number in a variable. Choose a random
#       number between 1 and 10.
#     - Ask the user for their guess.
#     - Verify if they were correct. If the player guesses correctly they win
#       the game, they should be congratulated and the game should end.
#     - If they guess incorrectly, give the player some direction. If they
#       guess too high let them know, if they guess too low, let them know.
#     - Don't forget to let your players know how many guesses they have left.
#       Your game should say something like:
#         "You have X guesses before the game is over enter a another number"
#     - If they don't guess correctly after 3 tries, display that the player
#       lost and that the game is over. Be nice and let them know what the
#       `secret_number` was.
#
###############################################################################

Once completed, save the file, commit the code to Git and push it to GitHub:

cd ~/Sites/secret_number/your_name_here/
git add secret_number.rb
git commit -m "Adding secret number homework"
git push origin master

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%