.


:




:

































 

 

 

 


3

1. .

2. .

, . .

1. . airship, . airship airplane balloon. airplane ( ) . balloon , ( ), ( ). .

2. building , . house, building . office, building .

3. , . : , .

4. : : (, , , ). , .

5. : : (, , , , ). , .

6. : : : (, , , , ). , .

7. : : : : : (, , , , ). , .

8. : , , . , .

9. : , , . , .

10. : : n . , .

( , ). . ScreenObject , , ,

-: .

- : .

: String ( ) Window ( ).

String , , ( ), .

Window - :

nmax (, ,..);

n ;

pObj ;

ColorFrame - ( ).

Window:

, , , ; << ( 1 0 , ).

: , . .

( UML-)

-     ScreenObject -
: x1, y1 : xr, yr (, , ): ColorGround : ScreenObject() : Show() : Move ()  
: pText : ColorText String( ). : String () : DrawText() : Show ()
(, ,..): nmax : n : pObj ( ): ColorFrame : Window ( ) : Window() : DrawShadow() : DrawFrame() : Show() << : operator <<

//

class ScreenObject

{ protected:

int x1, y1; //

int xr, yr; //

int ColorGround; // (, , )

ScreenObject (int Xleft, int Yup, int Xright, int Ydown, int ColGround);

virtual void Show (void);

void Move (int Dx, int Dy); }; //

 

class Window: public ScreenObject

{ int nmax;

int n;

int ColorFrame;

ScreenObject **pObj;

public:

Window (int Xleft, int Yup, int Xright, int Ydown, int ColGround,

int ColFrame, unsigned MaxObj);

// , ,

//

void Show (void);

void DrawFrame (void);

void DrawShadow (void);

int operator << (ScreenObject *obj); };

 

class String: public ScreenObject

{ char * pText;

int ColorText;

public:

String (int xleft, int yup, int ColGround, int ColText, char *Text);

void Show (void);

void DrawText (void); };

 

//

#include <stdio.h >

#include <conio.h >

// class ScreenObject

ScreenObject:: ScreenObject (int Xleft, int Yup, int Xright, int Ydown,

int ColGround)

{ x1 = Xleft; y1 = Yup; xr = Xright; yr = Ydown; ColorGround = ColGround; }

void ScreenObject:: Show (void)

{ int i, j;

textbackground (ColorGround);

for(j = y1; j <= yr; j ++) //

for(ji= x1; i <= xr; i ++) //

{ gotoxy (i, j); cprintf ( ); } }

void ScreenObject:: Move (int Dx, int Dy)

{ x1 += Dx; y1 += Dy; { xr += Dx; yr += Dy; }

 

// class String

String:: String (int xleft, int yup, int ColGround, int ColText, char *Text):

ScreenObject (xleft, yup, xleft + strlen(Text, yup, ColGround)

{ ColorText = ColText;

pText = new char [strlen(Text)+1];

if (pText) strcpy (pText, Text); }

void String:: DrawText (void);

{ textcolor (ColorText);

gotoxy (x1, y1);

cprintf (%s , pText); }

void String:: Show (void)

{ ScreenObject:: Show (); //

DrawText (); } //

 

// Class Window

Window:: Window (int Xleft, int Yup, int Xright, int Ydown, int ColGround,

int ColFrame, unsigned MaxObj):

ScreenObject (int Xleft, int Yup, int Xright, int Ydown, int ColGround)

{ ColorFrame = ColFrame;

nmax = MaxObj;

pObj = new ScreenObject *[nmax]; //

if (! pObj) nmax = 0; //

n = 0; }

void Window:: DrawFrame (void)

{ int i;

textcolor (ColorFrame);

for (i = x1; i <= xr; i++)

{ gotoxy (i, y1); cprintf (_ ); //

gotoxy (i, yr); cprintf (_); // }

for (i = y1+1; i < yr; i++)

{gotoxy (x1, i); cprintf (_ ); //

gotoxy (xr, i); cprintf (_); // } }

void Window:: DrawShadow (void)

{ int i;

textcolor (BROUN);

for (i = x1 +1; i <= xr+1; i++)

{ gotoxy (i, yr+1); cprintf (_ ); // }

for (i = y1+1; i <= yr; i++)

{gotoxy (xr+1, i); cprintf (_ ); // } }

int Window:: operator << (ScreenObject *obj)

{ if (n = = nmax) return 0; //

pObj[n] = obj;

n++;

obj -> Move (x1, y1);

return 1; }

void Window:: Show (void)

{ int i;

ScreenObject:: Show ();

DrawShadow ();

DrawFrame ();

for { i = 0; i < n; i++) // ,

pObj[i] -> Show (); // Show(),

// .. pObj

// , , , , ScreenObject

}

 

void main()

{

Window *wn;

String *str;

// ;

//

wn = new Window (5, 5, 20, 20, BLUE, WHITE, 5);

// new String()

//

str = new String(2, 2, GREEN, BLACK, X-X);

*wn << str;

str = new String(4, 4, GREEN, BLACK, X-X);

*wn << str;

str = new String(6, 6, GREEN, BLACK, X-X);

*wn << str;

wn -> Show ();

getch ();

}



<== | ==>
samp ob (88); // 88 | 4.2
:


: 2016-12-31; !; : 1175 |


:

:

, , .
==> ...

1784 - | 1465 -


© 2015-2024 lektsii.org - -

: 0.027 .