Скачиваний:
12
Добавлен:
01.05.2014
Размер:
4.16 Кб
Скачать
//File CPolygon.cpp
//Naznachenie: Opredelenie funkcij klassa "elementy spiska"
//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;
	     cout<<endl;
	     cprintf("\nKonstruktor CPolygon sozdaet ekzempliar klassa,s ID= ");

	     HistNum=HistNum+1;
	     Counter++;
	     cout<<GetID()<<endl
	     <<"HistNum= "<<GetHistNum()<<", Counter= "<<GetCounter();
	     cout<<endl;
	     FptrPoly=F0ptrPoly;
	     FptrPoly2=F0ptrPoly2;





	  }
/*
CPolygon::CPolygon( CPolygon &EPoly, CPolygon * )
//Konstruktor kopirovanija
	{   // float Sq=0,dx=0,dy=0,fi=0;
	    // int t=0;int i;

	     NextPoly=NextPoly0;

	     cout<<endl;
	     FptrPoly=new CTriangle(*(EPoly.FptrPoly));
	     FptrPoly2=new CTriangle(*(EPoly.FptrPoly2));
	     cprintf("Konstruktor kopirovanija CPolygon sozdal kopiju elementa");
	     cout<<endl;


	}
*/

//--------------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<<"ID treugolnika: "<<GetFptrPoly()->GetID();
             
		GetFptrPoly()->OutList(t);

		t=2;
		cout<<endl<<endl<<"ID treugolnika: "<<GetFptrPoly2()->GetID();
		GetFptrPoly2()->OutList(t);

     }



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;
	  int i=1;int t;
	     //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;}

		
//-------------------------Destruktor-------------
CPolygon::~CPolygon()
	 { float x0;
	 int t=0;
	   cout<<endl;
	   cprintf("~CPolygon razrushaet element klassa...");
	   cout<<"S ID= "<<GetID();endl;
	   if (FptrPoly)
	   {

	     cout<<endl;
	     cprintf("Zanchenie elementa  ");
	     FptrPoly-> OutList(t);
	     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;
	     cprintf("Element unichtozen...");
	     cout<<endl;
	     cprintf("Nazmite probel...");
	     cout<<endl;
	     getch();

         }
	 } 


#endif
Соседние файлы в папке Лабораторная работа 23