Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабораторная работа 33 / LAB 3 / CPOLYGON
.CPP//File CPolygon.cpp
//Naznachenie: Opredelenie funkcij klassa "mnogougolnik"
//Author: Pavel Morozov
//Redakcija: 2.0 13.04.07
#ifndef cpolygon_cpp
#define cpolygon_cpp
#include<iostream.h>
#include<math.h>
#include<conio.h>
#include<stdio.h>
#include"CTriangl.h"
#include"cpolygon.h"
#include"CTriangl.cpp"
//--------------------Konstruktor--------------------------
CPolygon::CPolygon(CTriangle *F0ptrPoly,CTriangle *F0ptrPoly2):ID(HistNum+1)
{ // float Sq=0,dx=0,dy=0,fi=0;
// int t=0;int i;
textcolor(9);
HistNum=HistNum+1;
Counter++;
cout<<endl<<endl;
cprintf("\nKonstruktor CPolygon sozdaet ekzempliar klassa,s ID= ");
cout<<GetID();
cprintf(", HistNum= ");
cout<<GetHistNum();
cprintf(", Counter= ");
cout<<GetCounter()<<endl;
FptrPoly=F0ptrPoly;
FptrPoly2=F0ptrPoly2;
textcolor(15);
}
//--------------Funkcii interfeisa-----------------------
void CPolygon::SetFptrPoly( CTriangle *F0ptrPoly,CTriangle *F0ptrPoly2 )
//Ustanovit ukazatel na element
{ FptrPoly=F0ptrPoly;
FptrPoly2=F0ptrPoly2;
}
CTriangle *CPolygon::GetFptrPoly()
{ return FptrPoly; }
//Poluchit ukazatel na element
CTriangle *CPolygon::GetFptrPoly2()
{ return FptrPoly2; }
//Poluchit ukazatel na element
void CPolygon::OutListPoly()
{
textcolor(15);
int t;
t=1;
cout<<endl<<endl;
// textcolor(GetFptrPoly()->GetColour());
cprintf("ID treugolnika: ");
cout<<GetFptrPoly()->GetID();
GetFptrPoly()->OutList(t);
t=2;
// textcolor(GetFptrPoly2()->GetColour());
cout<<endl<<endl;
cprintf("ID treugolnika: ");
cout<<GetFptrPoly2()->GetID();
GetFptrPoly2()->OutList(t);
// textcolor(15);
}
void CPolygon::MovePoly(float dx,float dy)
{
// pervyj treugolnik
GetFptrPoly()->Move(dx,dy);
// vtoroj treugolnik
GetFptrPoly2()->Move(dx,dy);
}
void CPolygon::RotatePoly(CPoint &Q, float fi )
{
//pervyj treugolnik
GetFptrPoly()->Rotate(Q,fi);
//vtoroj treugolnik
GetFptrPoly2()->Rotate(Q,fi);
}
void CPolygon::SquarePoly()
{
textcolor(15);
float SquareP;float Sq;
//Atributy
// t=1;//pervyj treugolnik
cout<<"Ploshad pervogo treugolnika s ID = "
<<GetFptrPoly()->GetID()<<" :";
GetFptrPoly()->Square(Sq);
SquareP=Sq;
cout<<"Ploshad vtorogo treugolnika s ID = "
<<GetFptrPoly2()->GetID()<<" :";
GetFptrPoly2()->Square(Sq);
cout<<"Ploshad mnogougolnika s ID = "<<GetID()<<" : ";
cout<<SquareP+Sq;
}
unsigned int CPolygon::GetID()
//Poluchit ukazatel na predydushij element
{ return ID;}
unsigned int CPolygon::GetHistNum()
// Poluchit kolichestvo sozdannyh objektov
{ return HistNum;}
unsigned int CPolygon::GetCounter()
// Poluchit kolichestvo sushestvujushih objektov
{return Counter;}
void CPolygon::GetXY(float &x_1,float &y_1,float &x_2,float &y_2,float &x_3,float &y_3,float &x_4,float &y_4)
{
int t=1;
GetFptrPoly()->GetXY(t,x_1,y_1,x_2,y_2,x_3,y_3,x_4,y_4);
t=2;
GetFptrPoly2()->GetXY(t,x_4,y_4,x_2,y_2,x_3,y_3,x_4,y_4);
}
//-------------------------Destruktor-------------
CPolygon::~CPolygon()
{ float x0;
int t=0;
textcolor(10);
cout<<endl;
cprintf("~CPolygon razrushaet element klassa...");
cprintf("S ID= ");cout<<GetID();endl;
if (FptrPoly)
{
cout<<endl;
cprintf("Zanchenie elementa ");
FptrPoly-> OutList(t);
textcolor(10);
cout<<endl;
delete FptrPoly;
cout<<endl;
cprintf("Element unichtozen...");
cout<<endl;
cprintf("Nazmite probel...");
cout<<endl;
getch();
}
// cout<<endl;
if (FptrPoly2)
{
cout<<endl;
cprintf("Zanchenie elementa ");
FptrPoly2-> OutList(t);
cout<<endl;
delete FptrPoly2;
cout<<endl;
textcolor(10);
cprintf("Element unichtozen...");
cout<<endl;
cprintf("Nazmite probel...");
cout<<endl;
getch();
textcolor(15);
}
}
#endif
Соседние файлы в папке LAB 3