-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethods.rb
More file actions
42 lines (39 loc) · 1.01 KB
/
methods.rb
File metadata and controls
42 lines (39 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 旅行行き先表示
def itinerary(plans)
puts "旅行プランを選択してください"
plans.each.with_index(1) do |plan, i|
puts "#{i}. #{plan[:place]}旅行 (¥#{plan[:price]})"
end
end
# 旅行行き先選択
def select_destination(plans)
print "プランを選択 >"
plan_number = gets.to_i
if plan_number < 1 || 3 < plan_number
puts "1〜3の数字を入力して下さい"
exit
end
plans[plan_number - 1]
end
# 旅行参加人数
def party(selected_plan)
puts "#{selected_plan[:place]}ですね、何人で行きますか?"
print "人数を入力 >"
how_many = gets.to_i
if how_many < 1
puts "人数を入力して下さい"
exit
end
how_many
end
#合計金額
def total_payment(selected_plan, how_many)
if how_many >= 5
puts "5人以上なので10%割引となります"
total = how_many * selected_plan[:price] * 9/10
print "合計金額: ¥#{total}"
else
total = how_many * selected_plan[:price]
print "合計金額: ¥#{total}"
end
end