Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Класс Массив квадратов и его сортировка / CPOINT
.CPP//Opisanie funkciy Cpoint
#include<iostream.h>
#include<math.h>
#include<values.h>
#include<conio.h>
#include "Cpoint.h"
int Cpoint::nextuid=0;
//-Invariant
int Cpoint::inv()
{if ((x<=10000)&&(x>=-10000)&&(y<=10000)&&(y>=-10000))
{return 1;}
else {return 0;}
}
//-Konstruktori
//Cpoint::Cpoint(){x=0;y=0;}
Cpoint::Cpoint(double R, double Fi) //-Konstruktor s parametrami
{ if ((R<=10000)&&(R>=-10000)&&(Fi<=2*3.14)) //Proverka predusloviya
{ //Popadanie v interval
//cout<<"Pred konctruktora tochki VIPOLNEN"<<endl;
x=R*cos(Fi); //Vichislenie atributov
y=R*sin(Fi);
nextuid++;
uid=nextuid;
}
else{cout<<"Pred konstructora tochki NE vipolnen!"<<endl;}
}
//-Selectori
double Cpoint::getR(){return sqrt(x*x+y*y);} //Vozvrat radiusa
double Cpoint::getFi(){return atan(y/x);} //Vozvrat ugla
double Cpoint::getX(){return x;}
double Cpoint::getY(){return y;}
//-Modifikatori
void Cpoint::setX(double x0) {x=x0;}
void Cpoint::setY(double y0) {y=y0;}
//-Operaciya
void Cpoint::Move(double dx, double dy)
{if ((x+dx<=10000)&&(x+dx>=-10000) //Proverka predusloviya
&&(y+dy<=10000)&&(y+dy>=-10000)) //Popadanie v interval
{
//cout<<endl<<"Pred move VIPOLNEN"<<endl<<endl;
x=x+dx; //Sdvig tochki
y=y+dy;
}else {cout<<endl<<"Pred move NE vipolnen"<<endl<<endl;}
}
//-Destruktor
Cpoint::~Cpoint()
{//cout<<endl<<"-------------------------------"<<endl<<
// "Tochka udalena.!!!!!!!!!!!!!!!!!!!!!!!"<<endl<<
// "Koordinati udalennoy tochki:"<<endl<<
// "Abscissa: "<<x<<endl<<
// "Ordinata: "<<y<<endl<<
// "Nomer: "<<uid<<endl;
// getch();
}
Соседние файлы в папке Класс Массив квадратов и его сортировка