poo punct

download poo punct

If you can't read please download the document

description

programare orientata obiect , clasa punct

Transcript of poo punct

# include "Header.h"Punct::Punct(int x, int y, char c) {this->x = x;this->y = y;this->c = c;}Punct::Punct(const Punct& P) {x = P.x;y = P.y;c = P.c;}Punct::~Punct() {}double Punct::distanta(const Punct & P1, const Punct& P2) {return sqrt((P1.x - P2.x)*(P1.x - P2.x) + (P1.y - P2.y)*(P1.y - P2.y));}int Punct::operator ==(const Punct& P) {if ((x == P.x) && (y == P.y))return 1;return 0;}int Punct::operator !=(const Punct& P) {if (*this == P)return 0;return 1;}ostream& operator P.y;return in;}Figura::Figura(const int n, const Punct P[MAX]){this->n = n;for (int i = 0; iP[i] = P[i];}Figura Figura::operator+(const Punct& P) {if (n < MAX) {Punct pp[100];for (int i = 0; iP[i];pp[n] = P;return Figura(n + 1, pp);}return Figura(*this);}Figura Figura::operator-(const Punct& P) {Punct pp[100];int nn = 0;for (int i = 0; i < n; i++) {if (this->P[i] != P)pp[nn++] = this->P[i];}return Figura(nn, pp);}double Figura::Perimetru() {double S = 0;for (int i = 0; i