forked from umple/umple
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeometricSystem.ump
277 lines (252 loc) · 8.43 KB
/
GeometricSystem.ump
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
//In order to see the class diagram with traits, please select option "GraphViz Class" in the menu "OPTIONS" and then checkout traits in the section "SHOW VIEW".
//developed by Vahdat Abdelzad, in August 2015.
//A root class for all elements (classes) in the system.
class RootClass{
abstract;
autounique id;
}
//A class which represent basic features of color.
class Color{
isA RootClass;
isA TEquality<TP1=Color>;
String rgb;
int getRed(){/*implementation */}
int getBlue(){/*implementation */}
int getGreen(){/*implementation */}
boolean isEqual(Color object){/*implementation */}
}
//used to draw geometric objects.
class Canvas {
isA RootClass;
void paint(Geometry g){/*implementation*/}
void update(Geometry g){/*implementation*/}
}
// a root abstract class for geometric objects.
class GeometricObject {
abstract;
isA RootClass;
isA TDrawable;
isA Subject<Observer=Canvas>;
}
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
//an abstract class for two-dimensional objects such as circles and rectangles.
class Shape2D{
abstract;
isA GeometricObject;
isA TDrawableWithEdge;
Point center;
abstract double getArea();
abstract double getPerimeterLength();
}
//an abstract class for three-dimensional objects such as cubes, prisms, cylinders and spheres.
class Shape3D {
abstract;
isA GeometricObject;
Point center;
abstract double volume();
abstract double surfaceArea();
}
// a class for points. A point doesn't have a dimension.
class Point {
isA GeometricObject;
isA TEquality<TP1=Point>;
double pX;
double pY;
boolean isEqual(Point object){/*implementation */}
}
//a class for lines. A line doesn't have an end.
class Line {
isA GeometricObject;
isA TEquality<TP1=Line>;
Point pA;
Point pB;
boolean isEqual(Line object){/*implementation */}
}
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
// an abstract class for curved two-dimensional shapes.
//Trait TComparable applied here because we wanted to have type-checking through parameters. For example, curved shapes can only be accepted in the related methods.
class CurvedShape{
abstract;
isA Shape2D;
isA TComparable <TP2=CurvedShape>;
}
// an abstract class for polygon.
//Trait TComparable applied here because we wanted to have type-checking through parameters. For example, polygon shapes can only be accepted in the related methods.
class Polygon {
abstract;
isA Shape2D;
isA TComparable <TP2=Polygon>;
0..1 -> 3..* Point vertices;
}
//three-dimensional shapes that must have flat faces.
//an abstract class for Polyhedra.
//Trait TComparable applied here because we wanted to have type-checking through parameters. For example, polyhedra shapes can only be accepted in the related methods.
class Polyhedra{
abstract;
isA Shape3D;
isA TComparable <TP2=Polyhedra>;
isA TDrawableWithEdge;
0..1-> * Point vertices;
}
//three-dimensional shapes that don't have any flat surface
//an abstract class for non-polyhedra shapes.
//Trait TComparable applied here because we wanted to have type-checking through parameters. For example, non-polyhedra shapes can only be accepted in related methods.
class NonPolyhedra{
abstract;
isA Shape3D;
isA TComparable <TP2=NonPolyhedra>;
}
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
class Circle{
isA CurvedShape;
double radius;
double getArea(){/*implementation */}
double getPerimeterLength(){/*implementation */}
boolean isLessThan(CurvedShape object){/*implementation */}
boolean isEqual(CurvedShape object){/*implementation */}
}
class Ellipse {
isA CurvedShape;
double majorAxis;
double minorAxis;
Point fFocus;
Point gFocus;
Point[2] getFoci(){/*implementation */}
double getArea(){/*implementation */}
double getPerimeterLength(){/*implementation */}
Line getTangent(){/*implementation */}
boolean isLessThan(CurvedShape object){}
boolean isEqual(CurvedShape object){}
}
class Quadrilateral{
isA Polygon;
double getArea(){/*implementation */}
double getPerimeterLength(){/*implementation */}
boolean isLessThan(Polygon object){}
boolean isEqual(Polygon object){}
}
class Rectangle{
isA Quadrilateral;
//overwrite for better calculation
double getArea(){/*implementation */}
//overwrite for better calculation
double getPerimeterLength(){/*implementation */}
}
class ArbitraryPolygon{
isA Polygon;
double getArea(){/*implementation */}
double getPerimeterLength(){/*implementation */}
boolean isLessThan(Polygon object){}
boolean isEqual(Polygon object){}
}
class Sphere{
isA NonPolyhedra;
double radius;
double volume(){/*implementation */}
double surfaceArea(){/*implementation */}
boolean isEqual(NonPolyhedra object){/*implementation */}
boolean isLessThan(NonPolyhedra object){/*implementation */}
}
class Torus {
isA NonPolyhedra;
double radius_r;
double radiusr_R;
double theta;
double phi;
double volume(){/*implementation */}
double surfaceArea(){/*implementation */}
boolean isEqual(NonPolyhedra object){/*implementation */}
boolean isLessThan(NonPolyhedra object){/*implementation */}
}
class Cylinder{
isA NonPolyhedra;
double radius;
double height;
double volume(){/*implementation */}
double surfaceArea(){/*implementation */}
boolean isEqual(NonPolyhedra object){/*implementation */}
boolean isLessThan(NonPolyhedra object){/*implementation */}
}
class Cone{
isA NonPolyhedra;
double radius;
double height;
double sideLength;
double volume(){/*implementation */}
double surfaceArea(){/*implementation */}
boolean isEqual(NonPolyhedra object){/*implementation */}
boolean isLessThan(NonPolyhedra object){/*implementation */}
}
class Cube{
isA Polyhedra;
double edgeLength;
double volume(){/*implementation */}
double surfaceArea(){/*implementation */}
boolean isEqual(Polyhedra object){/*implementation */}
boolean isLessThan(Polyhedra object){/*implementation */}
}
class RectangularPrism{
isA Polyhedra;
double length;
double width;
double height;
double volume(){/*implementation */}
double surfaceArea(){/*implementation */}
boolean isEqual(Polyhedra object){/*implementation */}
boolean isLessThan(Polyhedra object){/*implementation */}
}
class TriangularPyramid{
isA Polyhedra;
double slideLength;
double height;
double volume(){/*implementation */}
double surfaceArea(){/*implementation */}
boolean isEqual(Polyhedra object){/*implementation */}
boolean isLessThan(Polyhedra object){/*implementation */}
}
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
//used for all elements that can be just compared regarding being equal or not. These elements cannot compare regarding being either bigger or smaller.
//for example: point, line
trait TEquality<TP1>{
abstract boolean isEqual(TP1 object);
boolean isNotEqual(TP1 object){/*implementation */}
}
//used for elements which can be compared regarding being equal, bigger, smaller, etc.
//for example, 2-dimensional shapes.
trait TComparable<TP2>{
isA TEquality<TP1=TP2>;
abstract boolean isLessThan(TP2 object);
boolean isLessAndEqual(TP2 object){/*implementation */}
boolean isBiggerThan(TP2 object){/*implementation */}
boolean isBiggerAndEqual(TP2 object){/*implementation */}
}
//For geometric objects that cannot have color for edges.
trait TDrawable {
0..1 -> * Color color;
int getRed(){/*implementation */}
int getBlue(){/*implementation */}
int getGreen(){/*implementation */}
void applyTransparency(int percentage){/*implementation */}
void applyPattern(int type){/*implementation */}
void applyColorFilter(int f){/*implementation */}
}
//For geometric objects that can have colors for filling and edges.
trait TDrawableWithEdge{
isA TDrawable;
int getERed(){/*implementation */}
int getEBlue(){/*implementation */}
int getEGreen(){/*implementation */}
void applyETransparency(int percentage){/*implementation */}
void applyEPattern(int type){/*implementation */}
void applyEColorFilter(int f){/*implementation */}
}
//this trait brings the features that a Subject must have in Observerable Pattern.
//It makes connection with Observer through a template parameter.
trait Subject <Observer> {
0..1 -> * Observer;
void notifyObservers() {/*implementation*/ }
}