Skip to content

Queues - Hyunji Kim - Random Menu #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions menu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
adjective = [
"hot",
"steamy",
"delicious",
"spicy",
"sweet",
"salty",
"sour",
"cold",
"crunchy",
"sticky"
]

cook_style = [
"fried",
"steamed",
"simmered",
"BBQ",
"boiled",
"baked",
"stir-fried",
"roasted",
"preserved",
"crushed"
]

foods = [
"crab",
"rice",
"beef",
"pork",
"chicken",
"eggplant",
"potato",
"bread",
"noodles",
"salmon"
]

class String
def is_upper?
self == self.upcase
end

def is_lower?
self == self.downcase
end
end

order_num = 1
i = 10
10.times do
num = rand(i)
adj = adjective[num]
adjective.delete(adj)

num1 = rand(i)
style = cook_style[num1]
# For BBQ(all upper case)
if style.is_lower?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch your indentation - this should be at the same level as the line above.

style_cap = style.capitalize
else
style_cap = style
end
cook_style.delete(style)

num2 = rand(i)
food = foods[num2]
foods.delete(food)

puts "#{order_num}. #{adj.capitalize} #{style_cap} #{food.capitalize}"
order_num += 1
i -= 1
end

10.times do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this bit of code for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have deleted this code. my mistake!

num = rand(10)
end
76 changes: 76 additions & 0 deletions menu_user_chooses_how_many.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
adjective = [
"hot",
"steamy",
"delicious",
"spicy",
"sweet",
"salty",
"sour",
"cold",
"crunchy",
"sticky"
]

cook_style = [
"fried",
"steamed",
"simmered",
"BBQ",
"boiled",
"baked",
"stir-fried",
"roasted",
"preserved",
"crushed"
]

foods = [
"crab",
"rice",
"beef",
"pork",
"chicken",
"eggplant",
"potato",
"bread",
"noodles",
"salmon"
]

# Checking if a string is upper or lower case
class String
def is_upper?
self == self.upcase
end

def is_lower?
self == self.downcase
end
end

puts "How many menu items do you want? (enter 1 to 10)"
entered_num = gets.chomp.to_i
order_num = 1
i = 10
entered_num.times do
num = rand(i)
adj = adjective[num]
adjective.delete(adj)

num1 = rand(i)
style = cook_style[num1]
#making sure that all uppercase letters stay uppercase (BBQ)
if style.is_lower?
style1 = style.capitalize
else
style1 = style
end
cook_style.delete(style)

num2 = rand(i)
food = foods[num2]
foods.delete(food)
puts "#{order_num}. #{adj.capitalize} #{style1} #{food.capitalize}"
order_num += 1
i -= 1
end