-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkalitim.rb
More file actions
161 lines (120 loc) · 2.41 KB
/
kalitim.rb
File metadata and controls
161 lines (120 loc) · 2.41 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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# encoding: utf-8
require 'forwardable'
class Omurgalilar
def ye
"yemek yer."
end
def ic
"içer."
end
def uyu
"uyur."
end
end
class Hareket
def surun
"sürünür."
end
def adim
"adım atar."
end
def uc
"uçar."
end
end
class Insan < Omurgalilar
extend Forwardable
def_delegators :@hareket, :adim
def initialize
@hareket = Hareket.new
end
def ye
puts "İnsan #{super()}"
end
def ic
puts "İnsan #{super()}"
end
def uyu
puts "İnsan #{super()}"
end
def adimAt
puts "İnsan #{adim}"
end
end
class Kus < Omurgalilar
extend Forwardable
def_delegators :@hareket, :uc
def initialize
@hareket = Hareket.new
end
def ye
puts "Kuş #{super()}"
end
def ic
puts "Kuş #{super()}"
end
def uyu
puts "Kuş #{super()}"
end
def ucus
puts "Kuş #{uc}"
end
end
class Timsah < Omurgalilar
extend Forwardable
def_delegators :@hareket, :surun
def initialize
@hareket = Hareket.new
end
def ye
puts "Timsah #{super()}"
end
def ic
puts "Timsah #{super()}"
end
def uyu
puts "Timsah #{super()}"
end
def surunmek
puts "Timsah #{surun}"
end
end
class App
def initialize
@insan = Insan.new
@kus = Kus.new
@timsah = Timsah.new
end
def insan_run
#İnsan sınıfı uc ve surun metotlarını kullanamaz çünkü komposizyon ile aktarmadık.
insan.ye
insan.ic
insan.uyu
insan.adimAt
end
def kus_run
#Kus sınıfı adim ve surun metotlarını kullanamaz çünkü komposizyon ile aktarmadık.
kus.ye
kus.ic
kus.uyu
kus.ucus
end
def timsah_run
#Timsah sınıfı uc ve adim metotlarını kullanamaz çünkü komposizyon ile aktarmadık.
timsah.ye
timsah.ic
timsah.uyu
timsah.surunmek
end
private
attr_reader :insan, :kus, :timsah
end
def main
app = App.new
app.insan_run
print "\n"
app.kus_run
print "\n"
app.timsah_run
end
main