1 <!doctype html public "-//IETF//DTD HTML//EN">
\r
6 <TITLE>Klasy i obiekty</TITLE>
\r
8 <META NAME="GENERATOR" CONTENT="Internet Assistant for Word 1.0Z">
\r
9 <META NAME="AUTHOR" CONTENT="NOM">
\r
14 <H1><IMG SRC="loglanmm.gif" ALIGN="BOTTOM"> Chapter 1: Classes
\r
18 The still growing fascination of object-oriented programming dates
\r
19 to 1989 when several software companies offered compilers of object-oriented
\r
20 Pascal's, of C (C++ and Objective C) etc. We welcome this recognition
\r
21 of merits of object-oriented programming with satisfaction. Let
\r
22 us recall that classes and objects have more than 24 years of
\r
23 tradition. They appeared in Simula-67. Along the line of R&D
\r
24 concerning classes and their objects one can find the results
\r
25 achieved at the Institute of Informatics, University of Warsaw.
\r
26 We shall present many of them during these lectures.
\r
28 Notion of object has its roots in the well known structure of
\r
29 an Algol and Pascal-like program.
\r
31 Let us begin with the notion of module. In a program one can indicate
\r
32 several modules. The whole program is a module, every procedure
\r
33 and function declared in a program is a module too.
\r
35 In the language Loglan we have more kinds of modules:
\r
43 <LI>modules which serve the exceptions and/or signals - they are
\r
44 shortly called handlers.
\r
48 Let us look at the most external module of a program
\r
50 _______________________
\r
51 |<B>program</B> name (...) |
\r
53 | <<I>declarations</I>> e.g. | (It can contain other modules)
\r
54 | <B>var</B> x,y:real,a:bool;|
\r
58 | <<I>instructions</I>> e.g. |
\r
61 | <B>if</B> <B>not</B> a <B>then</B> ...<B>fi</B>;|
\r
62 | <B>while</B> ... |
\r
68 |_____________________|
\r
72 During an execution of a program the so called activation record
\r
73 of the above module is allocated in a memory. This is a prototype
\r
74 of the notion of object.
\r
76 _________________________
\r
77 |<I>memory of data</I> |
\r
80 R | y real -1.17 | This is an activation record,
\r
81 A | a bool true | sometimes called a dynamic ins-
\r
82 M | ..................... | tance of the (program) module.
\r
83 |<I>memory of instructions</I> |
\r
86 m | <B>if</B> <B>not</B> a <B>then</B> ... <B>fi</B>; |
\r
87 o | <B>while</B> ... |
\r
91 |_______________________|
\r
95 Object-oriented programming develops the above remarks and enriches
\r
96 the image the reader could build from them. In particular, object-oriented
\r
97 programming requires more frames and assumes a wider spectrum
\r
98 of the types of frames. Objects are just one type of frames appearing
\r
101 More frames! Where they are coming from? Can we recognize them
\r
102 in our Pascal practice? Yes, they arise during execution of procedure
\r
103 statements. How? They are known under the name of activation records
\r
104 or dynamic instances of procedures.
\r
106 An example, a snapshot of program's execution may look like:
\r
108 The above picture is a snapshot of an execution of the main program
\r
109 taken in the moment when in the main program we executed a <B>call
\r
110 </B>g procedure instruction, which caused the creation of an activation
\r
111 record for g and its execution, which in turn executed a <B>call
\r
112 </B>f procedure instruction, which caused the creation of (1st)
\r
113 instance of an activation record for f procedure and ...
\r
115 __________________________________________________
\r
117 __|______________ _____________|____ | |
\r
118 | <I>activ.rec</I> f | | <I>activ.rec. </I>g | | |
\r
119 | ÆÍÍÍÍÍ>͵ | | |
\r
120 | <I>(1st instance)</I>| | <I>(1st instance)</I> | | |
\r
121 | | | | ____________
\r
122 | | |<I> ______________</I> ====> | <I>Main</I> |
\r
123 | <I>____________</I> | | | | |
\r
124 | ... | | <B>call</B> f | |f: <B>proc</B> |
\r
125 | <B>call </B>f | | | | |
\r
126 | | | | |g: <B>proc</B> |
\r
128 ----------------- ------------------ |<I>_________</I> |
\r
130 | _________________________________>___|<B>call </B>g |
\r
131 ________________ __________________ | |
\r
132 | <I>activ.rec. </I>f | | <I>activ.rec. </I>f ÃÄÄÄÄ>Ä´ |
\r
133 | ÆÍ<ÍÍ͵ | ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
134 | <I>(2nd instance)</I> | | <I>(3rd instance)</I> |
\r
136 | <I>_____________</I> | | |
\r
138 | <B>call </B>f | | ... |
\r
140 |________________| |_________________|
\r
144 The instance of main program is the static father of all remaining
\r
145 activation records. This may be denoted by single lines (static
\r
146 links) leading to the leftmost object. A static father of an object
\r
147 is to be searched when the processor finds an identifier e.g.
\r
148 a variable which is non-local for a currently executed object.
\r
149 This in turn may lead to further searches along the path of static
\r
150 links. In every snapshot the set of objects together with the
\r
151 set of all static links creates a tree. Every edge of this graph
\r
152 corresponds to the tree structure of module nesting in an obvious
\r
155 Another kind of arrows (double lines) leads from an object to
\r
156 its dynamic father i.e. to the object in which processor subsumes
\r
157 the execution of instructions when all the instructions of a current
\r
158 object are executed to the <B>end. </B>The<B> </B>graph<B> </B>structure
\r
159 of objects and dynamic links differs from the previous one and
\r
160 shows "who called who". Making use of our Pascal experience
\r
161 we would like to assert it is a straight line structure. Later
\r
162 we shall see that objects and coroutines enrich and complicate
\r
165 Let us think of a <I>scenario</I> for an activation record of
\r
168 <I>About Simula-67 <BR>
\r
169 </I>The origins of object oriented programming go back to 1967
\r
170 when O.-J.Dahl, K.Nygaard and B.Myhrhaug defined the language
\r
171 Simula-67. [books: SIMULA<B>begin</B> by G.Birtwistle, O.J.Dahl,
\r
172 Auerbach Publ. and Simula 67 by W.M.Bartol, H.Oktaba, PWN Publ.
\r
173 are worth reading].
\r
175 <I>about class <BR>
\r
176 </I>General structure of a class module is as follows:
\r
178 <B> unit </B><<I>name_of_class</I> >: <B> class</B> (<<I>formal parameters</I>>);
\r
179 <<I>local declarations
\r
180 of variables, procedures, functions and classes</I>! >
\r
182 <<I>instructions</I>>
\r
183 <B>end</B> <<I>name_of_class</I> >
\r
189 <B>unit </B>circle : <B> class</B> (center: point, radius: real);
\r
190 <B>unit</B> intersects: <B>function</B> (c: circle): line;
\r
191 {the function returns the line which passes through the intersection points of this circle object and the c circle object, NOTE! it might return <B>none </B>if the two circles have no common points, see how it is solved below }...
\r
192 <B>end</B> intersects;
\r
194 <B>if</B> r=0 <B>then</B> <B>raise </B>SignalNoCircle <B>fi
\r
199 Let us remark that the syntactic difference between a procedure
\r
200 declaration and class declaration is little: the keyword <U>procedure</U>
\r
201 is replaced by another keyword <U>class</U>. However, the semantics
\r
202 is entirely different as it will be seen from the diagram-scenario
\r
205 <I>declaration of variables of type class <BR>
\r
206 </I>One can assume that every declaration of a class introduces
\r
207 a new type, for it enables declarations of variables like:
\r
209 <B>var </B>x : circle
\r
214 Objects of classes can be generated by means of expressions (object
\r
215 generator) of the form <BR>
\r
216 <B>new</B> KLASA(<I>actual_parameters</I>> <BR>
\r
217 and stored in variables <BR>
\r
218 k:= <B>new</B> KLASA(<I>actual_paramts</I>) <BR>
\r
219 One module of a class can serve as a pattern for many objects
\r
221 x:= <B>new</B> circle(point1, 88); <BR>
\r
222 y:= <B>new</B> circle(<B>new</B> point(45,159), 644) <BR>
\r
223 they can have different names. The names help to acces objects
\r
226 and their internal structure <BR>
\r
227 x.center ... y.radius <BR>
\r
228 The values of the latter expressions will be correspondingly:
\r
231 scenario of an object looks as follows<A NAME="DDE_LINK1"></A><A NAME="DDE_LINK2"></A>
\r
235 <I>IMPORTANT consequences</I> <BR>
\r
236 1. one can use initialization phase to execute an algorithm or
\r
237 to initialize objects.<BR>
\r
238 <B>EXERCISE</B>. write factorial algorithm using objects and no
\r
240 2. objects can be used as records, <BR>
\r
241 <B>EXERCISE</B>. write a piece of program which realizes a tree.
\r
243 3. one can send commands to objects, an object is able to execute
\r
244 the <B>call</B> commands referring to its local procedure declarations
\r
245 (and local functions too) <BR>
\r
246 e.g. call x.aProc(a) <BR>
\r
248 if aProc and aFun were declared in a class C and if x denotes
\r
249 an object of the class C.
\r
253 <B>unit</B> complex: <B> class</B> (re,im: real);
\r
254 <B>var</B> module: real;
\r
255 <B> unit </B>add:<B> function</B>(z: complex): complex;
\r
256 <B>begin</B> result:= <B> new</B> complex(re+z.re, im+z.im)
\r
258 <B>unit </B>mult:<B> function</B>(z: complex): complex;
\r
259 <B>begin</B> result:= <B> new</B> complex(re*z.re-im*z.im, re*z.im+z.re*im)
\r
261 <B>begin</B> module:= sqrt(re*re+im*im)
\r
262 <B>end </B>complex;
\r
264 Having such class one can create several objects of type complex and manipulate on them e.g.
\r
265 <B>program </B>UsingComplex;
\r
266 <B>unit</B> complex ... <B>end</B> complex;
\r
267 <B>var</B> c1,c2,z1,z2: complex;
\r
268 <B>begin</B> c1:= <B>new</B> complex(1,9); <I>{creation of complex number 1+9i}</I> c2:= <B>new</B> complex(-3,-21); <I> {second object of class complex}</I> z1:= c1.add(c2.mult(c1)); <I>{now z1=c1+(c2*c1))}</I> z2:= z1.mult(<B>new </B>complex(z1.re,-z1.im)) <I>{Note an object without a name, once used, it becomes a garbage}</I><B>end </B>UsingComplex
\r
272 <B>EXERCISE</B>. Write a similar program in Pascal and compare
\r
273 : how many parameters transmitted in an expression?, are the concepts
\r
274 of complex numbers encapsulated?
\r
276 EXAMPLE which follows introduces concepts of planar geometry and
\r
277 uses them in a prefixed block. The reader can run it and modify
\r
278 it as well. {This is the first Loglan program I wrote in December
\r
279 1981 to test the compiler.} <BR>
\r
282 <B>program</B> CircumscribedCircle;
\r
284 <B>unit</B> GEOPLAN : <B>class</B>;
\r
285 (* This class is in fact a problem oriented language, it offers various facilities for problem solving in the field of analitical planar geometry.
\r
286 <I>The class has the following structure:</I> <I>remark the correspondence between software notions of class, procedure, function and</I> <I>the notions of general algebra: algebraic structure, sorts and operations </I>
\r
288 GEOPLAN <----- class <I>algebraic structure</I> / | \
\r
291 POINT CIRCLE LINE <----- classes <I>sorts</I> / | \ | / | \
\r
292 / | \ | / | \ <I>operations</I> / | | | | | \ <--|
\r
294 opera- EQUALS DIST | | MEETS | \ |
\r
295 ERROR | | ERROR \ tions
\r
300 <I>*)</I> <B>unit</B> POINT : <B>class</B>(X,Y : REAL);
\r
301 <B>unit</B> EQUALS : <B>function</B> (Q : POINT) : BOOLEAN;
\r
302 <B>begin</B> RESULT:= Q.X=X <B>and</B> Q.Y=Y ;
\r
305 <B>unit</B> DIST : <B>function</B> (P : POINT) : REAL;
\r
306 <I>(* DISTANCE BETWEEN THIS POINT AND POINT P *)</I> <B>begin</B> <B>if</B> P = <B>none</B> <B>then</B> <B>call</B> ERROR
\r
307 <B>else</B> <B>result</B>:= SQRT((X-P.X)*(X-P.X)+(Y-P.Y)*(Y-P.Y))
\r
308 <B>fi</B> <B>end</B> DIST;
\r
311 <B>unit</B> <B>virtual</B> ERROR : <B>procedure</B>;
\r
312 <B>begin</B> WRITELN(" THERE IS NO POINT")
\r
317 <B>unit</B> CIRCLE : <B>class</B> (P : POINT, R : REAL);
\r
318 <I>{ THE CIRCLE IS REPRESENTED BY ITS CENTER P AND THE RADIUS R }</I>
\r
319 <B>unit</B> INTERSECTS : <B>function</B> (C : CIRCLE) : LINE;
\r
320 <I>(* IF BOTH CIRCLES INTERSECT AT 2 POINTS, THE LINE JOINING THEM
\r
321 IS RETURNED. IF CIRCLES INTERSECT AT ONE POINT, IT IS TANGENT
\r
322 TO BOTH OF THEM. OTHERWISE PERPENDICULAR BISECTION OF THEIR CENTRES IS RETURNED *)</I> <B>var</B> R1,R2 : REAL;
\r
323 <B>begin</B> <B>if</B> C=/= <B>none</B> <B>then</B> R1:= R*R-P.X*P.X-P.Y*P.Y;
\r
324 R2:= C.R*C.R-C.P.X*C.P.X-C.P.Y*C.P.Y;
\r
325 <B>result</B> := <B>new</B> LINE (P.X-C.P.X,P.Y-C.P.Y,(R1-R2)/2);
\r
326 <B>fi</B> <B>end</B> INTERSECTS;
\r
328 <B>begin</B> <B>if</B> P=<B>none</B>
\r
329 <B>then</B> WRITELN (" WRONG CENTRE")
\r
330 <B>fi</B> <B>end</B> CIRCLE;
\r
333 <B>unit</B> LINE : <B>class</B> (A,B,C : REAL);
\r
334 <I>{LINE IS REPRESENTED BY COEFFICIENTS OF EQUATION AX+BY+C=0 }</I>
\r
336 <B>unit</B> MEETS : <B>function</B> (L : LINE) : POINT;
\r
337 <I> (* IF TWO LINES INTERSECT function MEETS RETURNS THE POINT
\r
338 OF INTERSECTION, OTHERWISE RETURNS NONE *)</I> <B>VAR</B> T : REAL;
\r
339 <B>begin</B> <B>if</B> L =/= <B>none</B> <B>and</B> <B>not</B> PARALLELTO (L)
\r
340 <B>then</B> T := 1/(L.A*B-L.B*A);
\r
341 <B>result</B> := <B>new</B> POINT (-T*(B*L.C-C*L.B),
\r
343 <B>else</B> <B>call</B> ERROR
\r
344 <B>fi</B> <B>end</B> MEETS;
\r
345 <B>unit</B> PARALLELTO : <B>function</B> (L : LINE) : BOOLEAN;
\r
346 <B>begin</B> <B>if</B> L=/= <B>none</B> <B>then</B> <B>if</B> A*L.B-B*L.A = 0.0
\r
347 <B>then</B> <B>result</B>:=TRUE; WRITELN(" zle");
\r
348 <B>else</B> <B>result</B>:=FALSE; WRITELN(" dobrze");
\r
350 <B>else</B> <B>call</B> ERROR
\r
351 <B>fi</B> <B>end</B> PARALLELTO;
\r
353 <B>unit</B> <B>virtual</B> ERROR : <B>procedure</B>;
\r
354 <B>begin</B> WRITELN(" THERE IS NO LINE")
\r
357 <B>var</B> D : REAL;
\r
359 <B>begin</B> <I>(* NORMALIZATION OF COEFFICIENTS *)</I> D := SQRT(A*A+B*B);
\r
361 <B>then</B> WRITELN( " ZLE, ZERO"); <B>call</B> ERROR
\r
362 <B>else</B> A := A/D;
\r
365 <B>fi</B> <B>end</B> LINE;
\r
367 <B>end</B> GEOPLAN;
\r
372 <B>pref</B> GEOPLAN <B>block</B><I> (* THE LANGUAGE GEOPLAN IS USED FOR FINDING THE CIRCLE CIRCUMSCRIBED ON A GIVEN TRIANGLE:</I>
\r
376 / .<-\------- CENTRE
\r
379 <I>*)</I> <B>taken</B> POINT,LINE,CIRCLE;
\r
381 <B>var</B> P,Q,R,CENTRE : POINT,
\r
384 RADIUS, X1,Y1 : REAL;
\r
386 <B>begin</B> <B>do</B> WRITELN("THIS PROGRAM FINDS THE CENTRE AND RADIUS OF ");
\r
387 WRITELN(" THE CIRCLE CIRCUMSCRIBED ON A GIVEN TRIANGLE ");
\r
388 WRITELN(" GIVE THE VERTICES COEFFICIENTS OF A TRIANGLE");
\r
389 WRITELN(" X1,Y1= ?? ??");
\r
391 P := <B>new</B> POINT(X1,Y1);
\r
392 WRITELN(" ",X1," ",Y1);
\r
393 WRITELN(" X2,Y2= ?? ??");
\r
395 Q := <B>new</B> POINT(X1,Y1);
\r
396 WRITELN(" ",X1," ",Y1);
\r
397 WRITELN(" X3,Y3= ?? ??");
\r
399 R := <B>new</B> POINT (X1,Y1);
\r
400 WRITELN(" ",X1," ",Y1);
\r
402 RADIUS := P.DIST(Q) + Q.DIST(R);
\r
403 C1 := <B>new</B> CIRCLE (P,RADIUS);
\r
404 C2 := <B>new</B> CIRCLE (Q,RADIUS);
\r
405 C4 := <B>new</B> CIRCLE (R,RADIUS);
\r
407 L1 := C2.INTERSECTS(C1);
\r
408 <I> (*THE PERPENDICULAR BISECTOR OF THE SIDE PQ*)</I> L2 := C2.INTERSECTS(C4);
\r
409 <I> (*THE PERPENDICULAR BISECTOR OF THE SIDE QR *)</I>
\r
410 CENTRE := L1.MEETS(L2);
\r
412 <B>if</B> CENTRE = <B>none</B> <B>then</B> WRITELN(" ALL POINTS LAY ON THE SAME LINE");
\r
413 <B>else</B> WRITELN(" THE CIRCUMSCRIBED CIRCLE IS AS FOLOWS:");
\r
414 WRITELN(" CENTRE = (",CENTRE.X,',',CENTRE.Y,')');
\r
415 WRITELN(" RADIUS = ",CENTRE.DIST(P));
\r
416 <B>fi</B> <B>od</B> <B>end
\r
418 The static structure of modules in the above program is the tree
\r
426 GEOPLAN <B>pref</B> GEOPLAN <B>block</B>
\r
437 EQUALS DIST | | MEETS | \
\r
446 The edges lead from a module to its static father (up). The module GEOPLAN and the block prefixed with the name GEOPLAN are in another relation: namely of prefixing, or inheritance. We shall develop this remark later. What is worth noting here is that the structure of GEOPLAN remains intact. This is due to the fact that the class GEOPLAN encapsulates the structure of internal classes and modules.
\r
450 Let us view a few snapshots.
\r
452 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ The initial snapshot shows just one
\r
453 |<B>program</B> | dynamic instance of the main prog-
\r
454 | ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ | ram.
\r
456 | | | | The only instruction to be execu-
\r
457 | | | | ted is the instruction of prefixed
\r
460 | ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ |
\r
462 | ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ |
\r
463 | |<B>block</B> | | ---- block prefixed with GEOPLAN
\r
469 | ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ |
\r
471 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
\r
473 Just before the first writeln ... instruction
\r
475 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿SL ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
\r
476 |program ÃÄÄ<ÄÄÄÄÄÄÄÄÄ´GEOPLAN <B>block</B> |
\r
477 | ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ |DL | |
\r
478 | |GEOPLAN | ÆÍÍ<ÍÍÍÍÍÍÍÍ͵ all features of |
\r
479 | | | | | GEOPLAN inhtd. |
\r
481 | | | | | P point <B>none</B> |
\r
482 | | | | | Q point <B>none</B> |
\r
483 | ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ | | R point <B>none</B> |
\r
484 | | | C1 circle <B>none</B> |
\r
485 | ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ | | C2 circle <B>none</B> |
\r
486 | |<B>block</B> | | | C4 circle <B>none</B> |
\r
487 | | | | | L1 line <B>none</B> |
\r
488 | | | | | L2 line <B> none</B> |
\r
489 | | | | | RADIUS real 0 |
\r
492 | ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ | | |
\r
494 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
\r
495 This may be a snapshot just before the instruction putting radius to be equal the sum of distances PQ and QR. We omitted all SL links and DL links in order to simplify the picture.
\r
498 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄ¿
\r
499 |program | |GEOPLAN <B>block</B> | ÚÄÄÄÄÄ´ X real 4 |
\r
500 | ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ | | | | | Y real 6 |
\r
501 | |GEOPLAN | | | all features of | | ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
502 | | | | | GEOPLAN inhtd. | | ÚÄÄÄÄÄÄÄÄÄÄ¿
\r
503 | | | | | | | ÚÄÄÄ´ X real -4|
\r
504 | | | | | P point ÄÄÄÄÄÄÄÅÄÙ | | Y real 88|
\r
505 | | | | | Q point ÄÄÄÄÄÄÄÅÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
506 | ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ | | R point ÄÄÄÄÄÄÄÅÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄ¿
\r
507 | | | C1 circle <B>none</B> | | | X real -9|
\r
508 | ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ | | C2 circle <B>none</B> | ÀÄÄÄ´ Y real 23|
\r
509 | |<B>block</B> | | | C4 circle <B>none</B> | ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
510 | | | | | L1 line <B>none</B> |
\r
511 | | | | | L2 line <B> none</B> |
\r
512 | | | | | RADIUS real 0 |
\r
515 | ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ | | => radius:= ... |
\r
517 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
\r
522 This may be a snapshot just after the three circles were created.
\r
525 ___________________ ___________________ ÚÄÄÄÄÄÄÄÄÄÄ¿
\r
526 |program | |GEOPLAN <B>block</B> | ÚÄÄÄÄÄ´ X real 4 |
\r
527 | _______________ | | | | | Y real 6 |
\r
528 | |GEOPLAN | | | all features of | | ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
529 | | | | | GEOPLAN inhtd. | | ÚÄÄÄÄÄÄÄÄÄÄ¿
\r
530 | | | | | | | ÚÄÄÄ´ X real -4|
\r
531 | | | | | P point ÄÄÄÄÄÄÄÅÄÙ | | Y real 88|
\r
532 | | | | | Q point ÄÄÄÄÄÄÄÅÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
533 | |_____________| | | R point ÄÄÄÄÄÄÄÅÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄ¿
\r
534 | | | C1 circle ÄÄÄÄÄÄÅÄÄ¿| | X real -9|
\r
535 | _______________ | | C2 circle ÄÄÄÄÄÄÅÄ¿|ÀÄÄÄ´ Y real 23|
\r
536 | |<B>block</B> | | | C4 circle ÄÄÄÄÄÄÅ¿|ÀÄÄ¿ ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
537 | | | | | L1 line <B>none</B> ||ÀÄÄ¿| ÚÄÄÄÄÄÄÄÄÄÄ¿
\r
538 | | | | | L2 line <B> none</B> |ÀÄ¿ |ÀÄ´CENTER P |
\r
539 | | | | | RADIUS real 0 | | | ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
540 | | | | | | | ÀÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
\r
541 | | | | | | | |CENTER Q |
\r
542 | |_____________| | | => L1:= ... | | ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
543 | | | | | ÚÄÄÄÄÄÄÄÄÄÄ¿
\r
544 |_________________| |_________________| ÀÄÄÄÄ´CENTER R |
\r
545 ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
549 <TT>This may be a snapshot of situation in which two lines were
\r
550 created and their intersection point was found.</TT>
\r
552 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄ¿
\r
553 |program | |GEOPLAN <B>block</B> | ÚÄÄÄÄÄ´ X real 4 |
\r
554 | ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ | | | | | Y real 6 |
\r
555 | |GEOPLAN | | | all features of | | ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
556 | | | | | GEOPLAN inhtd. | | ÚÄÄÄÄÄÄÄÄÄÄ¿
\r
557 | | | | | | | ÚÄÄÄ´ X real -4|
\r
558 | | | | | P point ÄÄÄÄÄÄÅÄÙ | | Y real 88|
\r
559 | | | | | Q point ÄÄÄÄÄÄÅÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
560 | ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ | | R point ÄÄÄÄÄÄÅÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄ¿
\r
561 | | | C1 circle ÄÄÄÄÄÄÅÄÄ¿| | X real -9|
\r
562 | ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ | | C2 circle ÄÄÄÄÄÄÅÄ¿|ÀÄÄÄ´ Y real 23|
\r
563 | |<B>block</B> | | | C4 circle ÄÄÄÄÄÄÅ¿|ÀÄÄ¿ ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
564 | | | | | L1 line ÄÄÄÄÄÄ¿||ÀÄÄ¿| ÚÄÄÄÄÄÄÄÄÄÄ¿
\r
565 | | | | | L2 line <B> </B>ÄÄÄÄÄ¿||ÀÄ¿ |ÀÄ´CENTER P |
\r
566 | | | | | RADIUS real 0 |ÀÅÄ¿| | ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
567 | | | | | CENTRE Ä¿ | | || ÀÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
\r
568 | | | | | | | | || |CENTER Q |
\r
569 | ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ | | => <B>if </B>CE|NTRE | | || ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
570 | | | | | | || ÚÄÄÄÄÄÄÄÄÄÄ¿
\r
571 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÅÄÙ |ÀÄÄÄÄ´CENTER R |
\r
572 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ | | ÀÄÄÄÄÄÄÄÄÄÄÙ
\r
573 ÚÄÄÄÄÄÄÄÄÁÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ | ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
\r
574 | X <I><B>coeff. of</B> </I>| |A real ... | ÀÄ´A real ... |
\r
575 | Y <I><B>solution</B> </I> | |B real ... | |B real ... |
\r
576 | | |C real ... | |C real ... |
\r
577 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
\r
580 <B>Exercises</B>. Add drawing functions as attributes of classes point, line, circle.
\r
581 Write the algorithm inverting a point w.r.t. a given circle.
\r