ООП / ООП / oop-ekz-tasks / CoRR(3)
.doc//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
class CoRR
{
private: // User declarations
public: // User declarations
double x;
double y;
__fastcall CoRR(int ax=0,int ay=0);
__fastcall CoRR(CoRR &Src);
void Get (int x,int y,CoRR &Src);
void Set (int ax,int ay,CoRR &Src);
CoRR operator+ (CoRR c1);
CoRR operator+ (double c1);
CoRR operator- (CoRR c1);
CoRR operator-- ();
CoRR operator* (CoRR c1);
CoRR operator/ (CoRR c1);
void operator= (CoRR c1);
bool operator> (CoRR c1);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <iostream.h>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
__fastcall CoRR::CoRR(int ax,int ay)
{
x=ax;
y=ay;
}
//---------------------------------------------------------------------------
__fastcall CoRR::CoRR(CoRR &Src)
{
x=Src.x;
y=Src.y;
}
//---------------------------------------------------------------------------
void CoRR::Get (int &ax,int &ay)
{
ax=x;
ay=y;
}
//---------------------------------------------------------------------------
void CoRR::Set (int ax,int ay,CoRR &Src)
{
Src.x=ax;
Src.y=ay;
}
//---------------------------------------------------------------------------
CoRR CoRR::operator+ (CoRR c1)
{
CoRR F;
F.x=x+c1.x;
F.y=y+c1.y;
return F;
}
//---------------------------------------------------------------------------
CoRR CoRR::operator+ (double c1)
{
CoRR F;
F.x=c1+x;
F.y=c1+y;
return F;
}
//---------------------------------------------------------------------------
CoRR CoRR::operator- (CoRR c1)
{
CoRR F;
F.x=x-c1.x;
F.y=y-c1.y;
return F;
}
//---------------------------------------------------------------------------
CoRR CoRR::operator-- ()
{
CoRR F;
F.x=x-0;
F.x=y-0;
return F;
}
//---------------------------------------------------------------------------
CoRR CoRR::operator* (CoRR c1)
{
CoRR F;
F.x=x*c1.x;
F.y=y*c1.y;
return F;
}
//---------------------------------------------------------------------------
CoRR CoRR::operator/ (CoRR c1)
{
CoRR F;
if (c1.x!=0||c1.y!=0){
F.x=x+c1.x;
F.y=y+c1.y;
return F;
}
else return 0;
}
//---------------------------------------------------------------------------
void CoRR::operator= (CoRR c1)
{
x=c1.x;
y=c1.y;
}
//---------------------------------------------------------------------------
bool CoRR::operator> (CoRR c1)
{
if (x>c1.x||y>c1.y) return true;
return false;
}
//---------------------------------------------------------------------------