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

fixed cafe bug #26

wants to merge 2 commits into from

Conversation

rani-i3
Copy link

@rani-i3 rani-i3 commented Aug 29, 2023

No description provided.

cafe.rb Outdated
@@ -1,4 +1,5 @@
# frozen_string_literal: true
# require 'debug'
Copy link

Choose a reason for hiding this comment

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

提出物からはコメントアウトでなくて消しましょう

cafe.rb Outdated
@@ -15,11 +16,12 @@
].freeze

def take_order(menus)
# binding.break
Copy link

Choose a reason for hiding this comment

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

同上です。提出物からは消しましょう

Copy link
Author

Choose a reason for hiding this comment

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

修正しました。

cafe.rb Outdated
@@ -30,5 +32,5 @@ def take_order(menus)
puts 'フードメニューはいかがですか?'
order2 = take_order(FOODS)

total = FOODS[order1][:price] + DRINKS[order2][:price]
total = FOODS[order2][:price].to_i + DRINKS[order1][:price].to_i
Copy link

Choose a reason for hiding this comment

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

これでOKです。しかし本質的にはorder1,2のようなわかりにくい命名が引き起こしがちな不具合ともいえます。したがってよりよい解答としては変数名の見直しまでするといいですね。修正は任意で結構です。

Copy link
Author

Choose a reason for hiding this comment

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

修正しました!今のコードはorder1はdrinkorderになって、食べ物の分はfoodorderになりました。

@@ -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.

同上です。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants