mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 07:10:42 -08:00
slight cleanup and fix typoed filename
This commit is contained in:
@@ -12,24 +12,21 @@ NUMBER_UPPER_BOUND = 100
|
|||||||
# want to be able to refer to methods before declaring them,
|
# want to be able to refer to methods before declaring them,
|
||||||
# so the code reads nicely from top to bottom.
|
# so the code reads nicely from top to bottom.
|
||||||
def main
|
def main
|
||||||
print_banner
|
print_banner_and_instructions
|
||||||
print_instructions
|
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
play_a_game
|
play_a_game
|
||||||
break unless yes?("\nTry again?")
|
break unless yes?("Try again?")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def print_banner
|
def print_banner_and_instructions
|
||||||
banner = "Creative Computing -- Morristown, New Jersey"
|
banner = "Creative Computing -- Morristown, New Jersey"
|
||||||
|
|
||||||
puts "Trap!".center(banner.size)
|
puts "Trap!".center(banner.size)
|
||||||
puts banner
|
puts banner
|
||||||
3.times { puts }
|
2.times { puts }
|
||||||
end
|
|
||||||
|
|
||||||
def print_instructions
|
|
||||||
return unless yes?("Instructions?")
|
return unless yes?("Instructions?")
|
||||||
|
|
||||||
puts <<~"END"
|
puts <<~"END"
|
||||||
@@ -93,7 +90,7 @@ def get_guesses(prompt)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def yes?(prompt)
|
def yes?(prompt)
|
||||||
print "#{prompt} "
|
print "\n#{prompt} "
|
||||||
answer = gets
|
answer = gets
|
||||||
return answer.downcase.start_with?("y")
|
return answer.downcase.start_with?("y")
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user