Skip to content

カフェプログラムのバグを修正しました#1

Open
s-tone-gs wants to merge 3 commits intomainfrom
debug
Open

カフェプログラムのバグを修正しました#1
s-tone-gs wants to merge 3 commits intomainfrom
debug

Conversation

@s-tone-gs
Copy link
Copy Markdown
Owner

以下四つのバグを修正しました。

  • 頼んだつもりのメニューが選択できない。
  • 最後の番号のメニューを選択するとエラーとなる。
  • お会計額が異様に高い。
  • 違う番号のドリンク、フードを注文したとき、お会計が正しくない。


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

Choose a reason for hiding this comment

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

この変数の見直しができているのは素晴らしいですね ✨
今後同じようなミスが起こることを防げるはずです。

cafe.rb Outdated
food_order_number = take_order(FOODS)

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

Choose a reason for hiding this comment

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

確かにここで .to_i すればバグは解消されるのですが、今回の場合 price を文字列として宣言する必要がないので、宣言の時点で数値とするようにしましょう。

Copy link
Copy Markdown
Owner Author

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