puts "=>Hello, please enter player1 name."
name1 = gets.chomp
puts "=>Hello, please enter player2 name."
name2 = gets.chomp
puts "=>hello #{name1} and #{name2}, let's play the black jack game."
def random_cards
first_card = rand(10) + 1
second_card = rand(10) + 1
total_card = first_card + second_card
{first_card: first_card, second_card: second_card, total_card: total_card}
end
player1_cards = random_cards
player1_first_card, player1_second_card, player1_total_card = player1_cards[:first_card], player1_cards[:second_card], player1_cards[:total_card]
puts "=>Player One's first card is: #{player1_first_card}, second card is #{player1_second_card}, total is #{player1_total_card}."
player2_cards = random_cards
player2_first_card, player2_second_card, player2_total_card = player2_cards[:first_card], player2_cards[:second_card], player2_cards[:total_card]
puts "=>Player Two's first card is: #{player2_first_card}, second card is #{player2_second_card}, total is #{player2_total_card}."
if player1_total_card < player2_total_card
puts "=> Player Two won!!"
elsif player1_total_card > player2_total_card
puts "=> Player One won!!"
else
puts "=> This is a tie game!"
end
Terminal
black_jack.rb: 1: syntax error, unexpected tIDENTIFIER, expecting $end
puts "=>Hello, ...er1 name."