def raw_status
timer = 5
end
def medium_status
timer = 10
end
def well_done_status
timer = 15
end
def process(default_parameter)
start_time = 0
until start_time >= default_parameter do
puts "Preparing your meal"
start_time += 1
end
p "Your steak is ready"
end_phase
end
def start_phase
p "Please select timer for your steak"
timer = gets.chomp.downcase
until (timer == "raw_status" || timer == "medium_status" || timer == "well_done_status") do
puts "System caot recognize your command. Please select from these three options 'raw_status', 'medium_status' or 'well_done_status."
timer = gets.chomp.downcase
end
if timer == "raw_status"
process(raw_status)
elsif timer == "medium_status"
process(medium_status)
else timer == "well_done_status"
process(well_done_status)
end
end
def end_phase
p "Would you like another steak?"
answer = gets.chomp.downcase
until (answer == "yes" || answer == "no")
puts "Please key in yes or no"
answer = gets.chomp.downcase
end
if answer == "yes"
start_phase
else answer == "no"
puts "System shutting down... Enjoy your meal."
end
end
start_phase
برچسب:
نویسنده: استخدام کار
تاريخ: چهارشنبه
22 ارديبهشت
1395 ساعت: 19:15