J
Jeremy Woertink
I am still new to ruby and programming itself. This is my first
programming language. My task that was given to me for practice was to
recreate the game BlackJack.
I have all my classes and all my methods defined, now I just want to
make the actual game. I am not doing any sort of GUI. Here is my code.
puts 'Welcome to the crazy world of Black Jack.'
puts "To start a new game type 'deal'."
puts "To quit the game type 'quit'."
game = Game.new
game.get_player_command
while true
puts 'Your hand is: '
@player.player_hand
puts 'The dealer hand is: '
@dealer.dealer_hand
puts "Do you want to 'hit' or 'stay'?"
@game.get_player_command
if @player.bust?
puts 'You lose...'
@game.game_over
else
@dealer.dealer_hit
if @dealer.bust?
puts 'You Win!'
@game.game_over
end
end
end
The problem I am running into is I get the error " uninitialized
constant Game (Name Error). How do I tell ruby to make a new game class
to start the game.
the whole code is here http://rafb.net/paste/results/3kQ9pr90.html
Also, if anyone can help me to understand how to end the game or any
other things you might find that can help I would greatly appreciate it.
programming language. My task that was given to me for practice was to
recreate the game BlackJack.
I have all my classes and all my methods defined, now I just want to
make the actual game. I am not doing any sort of GUI. Here is my code.
puts 'Welcome to the crazy world of Black Jack.'
puts "To start a new game type 'deal'."
puts "To quit the game type 'quit'."
game = Game.new
game.get_player_command
while true
puts 'Your hand is: '
@player.player_hand
puts 'The dealer hand is: '
@dealer.dealer_hand
puts "Do you want to 'hit' or 'stay'?"
@game.get_player_command
if @player.bust?
puts 'You lose...'
@game.game_over
else
@dealer.dealer_hit
if @dealer.bust?
puts 'You Win!'
@game.game_over
end
end
end
The problem I am running into is I get the error " uninitialized
constant Game (Name Error). How do I tell ruby to make a new game class
to start the game.
the whole code is here http://rafb.net/paste/results/3kQ9pr90.html
Also, if anyone can help me to understand how to end the game or any
other things you might find that can help I would greatly appreciate it.