Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def generate_question
- @random_number_1 = rand(20)
- @random_number_2 = rand(20)
- @answer = @random_number_1 + @random_number_2
- end
- def prompt_player_for_answer
- puts "#{@current_player.name}, what does #{@random_number_1} plus #{@random_number_2} equal?"
- @response = gets.chomp.to_i
- end
- def verify_answer
- if @response == @answer
- puts "Yesiiiir!!!"
- @current_player.increment_points
- else
- puts "Ball dont lie!!!"
- @current_player.decrement_lives
- end
- end
- def score_tracker
- puts "#{@player1.name} you have #{@player1.points} points and #{@player1.lives} lives left!"
- puts "#{@player2.name} you have #{@player2.points} points and #{@player2.lives} lives left!"
- puts "==========================================="
- end
- def end_game
- puts "#{@current_player.name}, YOU WIN!!!"
- switch_turn
- puts "#{@current_player.name}, YOU LOSE BITCH!!!"
- end
- def switch_turn
- if @current_player == @player1
- @current_player = @player2
- else
- @current_player = @player1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement