-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLab3_prog_UML.puml
150 lines (122 loc) · 2.99 KB
/
Lab3_prog_UML.puml
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
@startuml ClassesModel
enum CosmicObjectType {
STAR
ASTEROID
PLANET
GALAXY
SATALITE
}
interface Lightable {
+ double light()
}
interface Reflectable {
+ double reflect(Light otherLight)
}
interface Viewable {
+ String getView(CosmicObject viewPoint)
}
note bottom of Viewable
This interface is used for objects, that can be seen by humans
from other cosmic objects.
end note
CosmicObject -- CosmicObjectType
abstract class CosmicObject implements Viewable {
# CosmicObjectType type
# int brightness
# String name
# double radius
# double mass
+ CosmicObject(String name, double radius, double mass)
+ CosmicObjectType getType()
+ int getBrightness()
+ Strign getName()
}
note bottom of CosmicObject
This is the base class for all objects in the universe.
end note
class Star extends CosmicObject implements Lightable {
# CosmicObjectType type = STAR
+ Star(String name, double radius, double mass, int brightness)
+ String light()
}
class Sun extends Star {
# type = STAR
# name = Sun
# brightness = 50
# radius = 696 340
# mass = 1.98892 * 10^30
+ Sun()
}
class Earth extends CosmicObject implements Reflectable {
# type = PLANET
# brightness = 2
# name = Earth
# mass = 5.9742 * 10^24
# radius = 6371
+ Earth()
+ Light reflect(Light otherLight)
}
class Moon extends CosmicObject implements Reflectable {
# type = SATALITE
# brightness = 1
# name = Moon
# mass = 7.36 * 10^22
# radius = 1737.4
+ Moon()
+ Light reflect(Light otherLight)
}
class Sky implements Viewable {
# CosmicObject[] objects
+ String getView(CosmicObject viewPoint)
}
abstract class Human implements Viewable {
# String name
# CosmicObject location
+ String getName()
+ CosmicObject getLocation()
+ see(Viewable target)
+ read()
+ write()
+ draw()
}
note top of Human
This is the base class for all humans in the universe.
see() methods call getView() method of class Viewable object
Method read(), write() and draw() can check brightness of object before running.
end note
class Znayka extends Human {
# name = Znayka
+ Znayka()
+ see(Viewable target)
+ read()
+ write()
+ draw()
}
note top of Fuksy
I find out, that Fuksy, Seledochka and ProfessorZvizdochkin are Neznayka's companions.
end note
class Fuksy extends Human {
# name = Fuksy
+ Fuksy()
+ see(Viewable target)
+ read()
+ write()
+ draw()
}
class Seledochka extends Human {
# name = Seledochka
+ Seledochka()
+ see(Viewable target)
+ read()
+ write()
+ draw()
}
class ProfessorZvizdochkin extends Human {
# name = ProfessorZvizdochkin
+ ProfessorZvizdochkin()
+ see(Viewable target)
+ read()
+ write()
+ draw()
}
@enduml