- #include<iostream>
- #include<string>
- using namespace std;
- class Point{
- private:
- double x,y;
- public:
- Point(double x,double y){
- this->x=x;
- this->y=y;
- }
- Point(){
- }
- friend ostream& operator <<(ostream&, const Point&);
- friend istream& operator >> (istream&, Point&);
- void przesun(double dx, double dy){
- x+=dx;
- y+=dy;
- }
- void jednokladnosc(double k){
- x=x*k;
- y=y*k;
- }
- void symetriaOX(){
- y=-y;
- }
- void symetriaOY(){
- x=-x;
- }
- double getX(){
- return x;
- }
- double getY(){return y;}
- };
- class Trojkat{
- private:
- Point* a;
- Point* b;
- Point* c;
- public:
- Trojkat(){
- a = new Point();
- b = new Point();
- c = new Point();
- }
- Trojkat(Point aa,Point bb,Point cc){
- a = new Point(aa);
- b = new Point(bb);
- c = new Point(cc);
- }
- Trojkat(double ax,double ay,double bx,double by,double cx,double cy){
- this->a = new Point(ax,ay);
- this->b = new Point(bx,by);
- this->c = new Point(cx,cy);
- }
- Point* getA(){
- return a;
- }
- Point* getB(){
- return b;
- }
- Point* getC(){
- return c;
- }
- void przesun(double ax,double ay,double bx,double by,double cx,double cy)
- {
- a->przesun(ax,ay);
- b->przesun(bx,by);
- c->przesun(cx,cy);
- }
- void jednokladnosc(double ak){
- a->jednokladnosc(ak);
- b->jednokladnosc(ak);
- c->jednokladnosc(ak);
- }
- void symetriaOX(){
- a->symetriaOX();
- b->symetriaOX();
- c->symetriaOX();
- }
- void symetriaOY(){
- a->symetriaOY();
- b->symetriaOY();
- c->symetriaOY();
- }
- friend ostream& operator <<(ostream&, const Trojkat&);
- friend istream& operator >> (istream&, Trojkat&);
- ~Trojkat(){
- delete a;
- delete b;
- delete c;
- }
- };
- ostream& operator <<(ostream& os, const Point& pp)
- {
- os << "("<<pp.x <<", " << pp.y<<")";
- return os;
- }
- istream& operator >>(istream& is, Point& pp)
- {
- is >> pp.x >> pp.y;
- return is;
- }
- ostream& operator <<(ostream& os, const Trojkat& tr)
- {
- os << "["<<*(tr.a) <<", " << *(tr.b)<< "," <<*(tr.c)<< "]";
- return os;
- }
- istream& operator >>(istream& is, Trojkat& tr)
- {
- //is >> tr->a >> tr->b >> tr->c;
- return is;
- }
- int main(){
- Point p1;
- cout<<"Podaj wsp p1:";
- cin>>p1;
- Point p2(4.0,5.3);
- Point *wp3= new Point(2,0);
- cout<<"Punkty"<<p1<<p2<<*wp3;
- p1.jednokladnosc(2.0);
- p2.przesun(-1,2.5);
- wp3->symetriaOX();
- cout<<*wp3;
- cout<<p2;
- Trojkat tr1(1.0,1,4,5,2,0);
- cout<<"tr1="<<tr1;
- Trojkat tr2();
- //cout<<"Podaj wsp tr2:";
- //cin>>tr2;
- //Trojkat *wt3= new Trojkat(&p1,&p2,wp3);
- //cout<<"tr3="<<wt3;
- tr1.jednokladnosc(2.0);
- //tr2.przesun(-1,2.5);
- //wt3->symetriaOY();
- cout<<"tr1="<<tr1;
- // cout<<"tr2="<<tr2;
- // cout<<"tr3="<<*wt3;
- return 0;
- }