-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoop4.rb
85 lines (67 loc) · 1.22 KB
/
oop4.rb
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
module Cappucinator
def create_foam
prepare_milk
push_foam
end
private
def prepare_milk
puts "Select and boil the milk"
end
def push_foam
puts "We produce milk foam in the cup"
end
end
module LatteArt
private
def push_foam
puts "Beautiful patterns spread foam in the cup."
end
end
class CoffeMachine
def make_coffee
get_start
get_water(200)
get_beans(50)
coffe_ready
end
protected
def get_start
puts "Start"
end
def coffe_ready
puts "Coffee ready!"
end
def get_water(mls)
puts "Water #{mls}mls."
end
def get_beans(grams)
puts "Beans #{grams}grams."
end
end
class CappuccinoMachine < CoffeMachine
include Cappucinator
include LatteArt
def make_coffee
super
create_foam
end
end
class CapsuleCappuccino < CoffeMachine
include Cappucinator
def make_coffee
get_start
get_water(200)
prepare_capsule
create_foam
coffe_ready
end
protected
def prepare_capsule
puts "We reveal the capsule and fall asleep in the coffee container."
end
end
p capsulecappucino = CapsuleCappuccino.new
p capsulecappucino.make_coffee
p "="*30
p cappuccinomachine = CappuccinoMachine.new
p cappuccinomachine.make_coffee