Skip to content

Instantly share code, notes, and snippets.

@nech0701
Last active May 11, 2016 09:51
Show Gist options
  • Save nech0701/5426c2bc32d343e8e9b166741eda1e4e to your computer and use it in GitHub Desktop.
Save nech0701/5426c2bc32d343e8e9b166741eda1e4e to your computer and use it in GitHub Desktop.
git add: start_phase and end phase
git commit -m "added loop method for start phase and end phase to get the right input and shutting down system (quitting from the loop)"
require 'byebug'
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")
puts "System cannot recognize your command. Please try again."
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
@nech0701
Copy link
Author

git add: start_phase and end phase
git commit -m "added loop method for start phase and end phase to get the right input and shutting down system (quitting from the loop)"
require 'byebug'

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")
puts "System cannot recognize your command. Please try again."
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment