Skip to content
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

fixed cafe bug #26

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
10 changes: 3 additions & 7 deletions cafe.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# frozen_string_literal: true
# require 'debug'

DRINKS = [
{ name: 'コーヒー', price: '300' },
{ name: 'カフェラテ', price: '400' },
Expand All @@ -16,7 +13,6 @@
].freeze

def take_order(menus)
# binding.break
menus.each.with_index(1) do |menu, i|
puts "(#{i})#{menu[:name]}: #{menu[:price]}円"
end
Expand All @@ -27,10 +23,10 @@ def take_order(menus)
end

puts 'bugカフェへようこそ!ご注文は? 番号でどうぞ'
order1 = take_order(DRINKS)
drinkorder = take_order(DRINKS)
Copy link

Choose a reason for hiding this comment

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

細かいことをいうとスネークケースで書いたほうがいいのでdrink_orderが適切ですね


puts 'フードメニューはいかがですか?'
order2 = take_order(FOODS)
foodorder = take_order(FOODS)
Copy link

Choose a reason for hiding this comment

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

同上です。


total = FOODS[order2][:price].to_i + DRINKS[order1][:price].to_i
total = FOODS[foodorder][:price].to_i + DRINKS[drinkorder][:price].to_i
puts "お会計は#{total}円になります。ありがとうございました!"