-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComposite.rb
More file actions
72 lines (55 loc) · 776 Bytes
/
Composite.rb
File metadata and controls
72 lines (55 loc) · 776 Bytes
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
class Files
@@num=0
def initialize()
end
def geta
1
end
def show(dammy)
@@num+=1
puts "file#{@@num}"
end
end
class Directorys
@@num=0
@@sp =""
def initialize()
@file = []
end
def add(file)
@file << file
end
def geta
ans=1
@file.each do |obj|
ans += obj.geta
end
ans
end
def show(space)
@@num+=1
puts "directory#{@@num}{"
@file.each do |obj|
print "#{space}"
obj.show(space+" ")
end
print(space)
puts "}"
end
end
d1 = Directorys.new
d1.add(Files.new)
d1.add(Files.new)
d2 = Directorys.new
d2.add(Files.new)
d2.add(Files.new)
d1.add(d2)
d3 = Directorys.new
d3.add(Files.new)
d2.add(d3)
d2.add(Files.new)
d2.add(Files.new)
d1.add(Files.new)
d1.add(Files.new)
d1.show("")
puts "Amount of Data:#{d1.geta}"