All pastes #802532 Raw Edit

Someone

public text v1 · immutable
#802532 ·published 2007-11-30 11:31 UTC
rendered paste body
#include <iostream>
using namespace std;

class Figura{
      public:
      void draw(){
           cout << "to jst figura\n";}
      void move(){}
};
   
class Punkt{
      int x,y;
      public:
      void draw(){
           cout << "to jst punkt o wspolrzednych [" << x << " " << y << "]\n";}
      void move(int x1, int y1){
           x+=x1;
           y+=y1;}
      void move(Punkt px){
           x+=px.x;
           y+=px.y;}
      int getx(){return x;}
      int gety(){return y;}
      void setx(int n){x=n;}
      void sety(int n){y=n;}
      void setxy(int n1, int n2){x=n1; y=n2;}
      friend ostream& operator<<(ostream& ekran, const Punkt &p){
             ekran << "[" << p.x << "," << p.y <<  "]";}
      Punkt(){x=0; y=0;}
      Punkt(int n0, int n1){x=n0; y=n1;}
      Punkt(const Punkt &px){x=px.x; y=px.y;}
};

class Triangle:public Figura{
      Punkt p0,p1,p2;
      public:
      Punkt getp0(){return p0;}
      Punkt getp1(){return p1;}
      Punkt getp2(){return p2;}
      void setp0(int x, int y){p0.setxy(x,y);}   
      void setp1(int x, int y){p1.setxy(x,y);}
      void setp2(int x, int y){p2.setxy(x,y);}   
      void setp(Punkt a, Punkt b, Punkt c){
           //p0.setxy(a.getx(),a.gety()); 
           //p1.setxy(b.getx(),b.gety()); 
           //p2.setxy(c.getx(),c.gety());
           setp0(a.getx(),a.gety()); 
           setp1(b.getx(),b.gety()); 
           setp2(c.getx(),c.gety()); 
           }
      void draw(){
           cout << "to jest trojkat o wspolrzednych " << p0 << " " << p1 << " " << p2 << "\n";}
      void move(Punkt p){
           p0.move(p);
           p1.move(p);
           p2.move(p);
           }
};

class Triangle_Rownoboczny:public Triangle{
      Punkt p0,p1,p2;
      public:
      Punkt getp0(){return p0;}
      Punkt getp1(){return p1;}
      Punkt getp2(){return p2;}
      void setp0(int x, int y){p0.setxy(x,y);}   
      void setp1(int x, int y){p1.setxy(x,y);}
      void setp2(int x, int y){p2.setxy(x,y);}   
      void setp(Punkt a, Punkt b, Punkt c){
           //p0.setxy(a.getx(),a.gety()); 
           //p1.setxy(b.getx(),b.gety()); 
           //p2.setxy(c.getx(),c.gety());
           setp0(a.getx(),a.gety()); 
           setp1(b.getx(),b.gety()); 
           setp2(c.getx(),c.gety());}
      void draw(){
           cout << "to jest trojkat rownoboczny o wspolrzednych " << p0 << " " << p1 << " " << p2 << "\n";}
      void move(Punkt p){
           p0.move(p);
           p1.move(p);
           p2.move(p);
           }
};

class Linia:public Figura{
      Punkt p0, p1;
      public:
      void draw(){
           cout << "to jest linia o wspolrzednych " << p0 << " " << p1 << "\n";}
      void move(Punkt p){
           p0.move(p);
           p1.move(p);
           }
};

main(){
       Triangle t;
       t.setp0(3,8);
       t.setp1(-5,1);
       t.setp2(4,7);
       //t.draw();
       //t.getp1().draw();
       Figura* a;
       Triangle* b;
       Triangle_Rownoboczny* c;
       
       a=new Figura();
       b=new Triangle();
       c=new Triangle_Rownoboczny();
       a->draw();
       b->draw();
       c->draw();

       a=c;
       b=c;
       
       a->draw();
       b->draw();
       c->draw();
       
       cout << sizeof(Triangle) << endl << sizeof(Triangle_Rownoboczny) << endl << sizeof(Figura) << endl;
    
    "implementować to co na wykładzie (przesyłki pocztowe)"
    
    
system("pause");       
}