質問編集履歴
1
codeの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,28 +6,84 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
|
9
|
+
```ruby
|
10
10
|
|
11
|
-
|
11
|
+
puts "商品名を記入してください"
|
12
12
|
|
13
|
-
|
13
|
+
item1 =gets.chomp
|
14
14
|
|
15
|
-
|
15
|
+
puts "-------"
|
16
16
|
|
17
|
+
puts "商品名:#{item1}"
|
18
|
+
|
19
|
+
puts "値段を設定してください"
|
20
|
+
|
21
|
+
item2 = gets.chomp.to_i
|
22
|
+
|
23
|
+
puts "-------"
|
24
|
+
|
25
|
+
puts "値段:#{item2}円"
|
26
|
+
|
27
|
+
puts "個数を入力"
|
28
|
+
|
29
|
+
item3 =gets.chomp.to_i
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
class Menu
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
attr_accessor :name
|
42
|
+
|
43
|
+
attr_accessor :price
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
def info
|
48
|
+
|
49
|
+
return "#{self.name} #{self.price}円"
|
50
|
+
|
17
|
-
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
def get_total_price(count)
|
56
|
+
|
57
|
+
total_price = self.price * count
|
58
|
+
|
59
|
+
if count >= 3
|
60
|
+
|
61
|
+
total_price = total_price - 300
|
62
|
+
|
63
|
+
end
|
18
64
|
|
19
65
|
return total_price
|
20
66
|
|
21
|
-
end
|
67
|
+
end
|
22
|
-
|
23
|
-
.
|
24
|
-
|
25
|
-
.
|
26
|
-
|
27
|
-
.
|
28
|
-
|
29
|
-
puts get_total_price(3)
|
30
68
|
|
31
69
|
|
32
70
|
|
71
|
+
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
menu1 = Menu.new
|
78
|
+
|
79
|
+
menu1.name = item1
|
80
|
+
|
33
|
-
|
81
|
+
menu1.price = item2
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
puts get_total_price (item3)
|
88
|
+
|
89
|
+
```
|