#include "iostream.h"

class TFigure
{
    public:
    // ��������� ��� ���� �������� � ����������� �������� ������ (���������� �����,
    // ����������� ��� ������������� ��������� �������), � ��� ������ �� �������������
    // ������� ����� (�����������, � �������� ����) ������������� �� ������� �����
    TFigure(int numPoints, const char *s = ""):
            name(s), ptsAmount(numPoints)
    {
        // ��� ������ �������� ������ �����, � ����� ������
        pts = new TPoint[ptsAmount];
        cout << name << " created ..." << endl;

        for(int i = 0; i < ptsAmount; i++) {
            // � ���������� ��������� ����� ���� ����� ��
            // ��� - ����� ������������� �����, ���� ���� ��������� �������� ������� ����� ���
            // �������� �����-������ ������, ��� �����, ������� ��� ������ ����� ��� ������ ��
            // ���� ������� � ������, ��� �� ��� ������������ ��� ��������?
            TPoint p;
            cout << "Enter coordinates of apex" << i+1 << ":";
            cin >> p.x >> p.y;
            pts[i] = p;

        }
    }

    // � ��� ������ ��������� ����������, � � ��� - �������� �������...
    virtual ~TFigure()
    {
      delete [] pts;
    }

    // ��������� move_it ������ ���� � �� �� �������� ��� ���� (�� ������� ����,
    // ��� ��������� � ��������) �������, ���� ����� ��������� �� ���� � ������� �����,
    // ��������� �� ��� ����� ����� � ���������� �����, � �������� ������������ ������...

    // ����� ��� ���� ������������� ������ ������� �����������, ������ �� ������� ����� 
    // ���������� ����� �������� ������
    void move_it(int step_x, int step_y) {
        for(int i = 0; i < ptsAmount; i++)
        {
            pts[i].x += step_x;
            pts[i].y += step_y;
        }
    }

    // ���������� � ��� show_position ...
    void show_position() {
      for(int i = 0;i < ptsAmount; i++)
        cout << " (" << pts[i].x << ";" << pts[i].y << ") ";
    }

    struct TPoint
    {
        TPoint(int px = 0, int py = 0): x(px), y(py)
        {
        }
        int x, y;
    };

    virtual double getS() const = 0;

  private:
    const char *name;

  // � "����������" ������� ������ ����������, � ������� �� ������ ���� �������
  // ��������, ����� ��� �� ������� - ��������
  protected:
    int ptsAmount;
    TPoint *pts;
};

class TTriangle: public TFigure
{
  public:
    // �� ��������� ������ ����� ����� ������������ = 3 (���� ����� ���� �� ������ ������� ���:
    //  TTriangle(): TFigure(3, "triangle") {}
    // ,����� �� ��������� �������, ��������, ����������� - "������" � ������ ������...)
    TTriangle(int numPoints = 3) : TFigure(numPoints, "triangle") {
    }

    // ��� ������� �������, ��-����� ��� � ���� ���������� �������� ��������� !!!
    double getS() const
    {
      return 0.5*(pts[0].y*pts[1].x-pts[1].y*pts[0].x+
                  pts[1].y*pts[2].x-pts[2].y*pts[1].x-
                  pts[0].y*pts[2].x+pts[0].y*pts[0].x);
    }

};

class TPentagon: public TFigure
{
    public:
      // �����, ��� � � TTriangle, ����� ������� ��-�������...
      TPentagon(int numPoints = 5): TFigure(numPoints, "pentagon") {
    }

    double getS() const
    {
      return 12.0;
    }

};

char Compare(const TFigure &T1, const TFigure &T2)
{
    return (T1.getS() < T2.getS()) ? '<' : '>';
}


int main() {

  TTriangle T1;
  T1.show_position(); // �� ��� ����� ��������� () ��� ������ ������/�������, � � � ��� ����������
  cout << T1.getS() << endl; // �������
  T1.move_it(2,2); // ����������
  T1.show_position(); // ��������� ����� ����������
  cout << T1.getS() << endl; // ��������� �������
  // (� ���� ������ �������� ������� �� ������� �� ������)

  TPentagon T2;
  T2.show_position(); // �������
  cout << T2.getS() << endl; // �������
  T2.move_it(2,2); // ����������
  T2.show_position(); // ��������� ����� ����������
  cout << T2.getS() << endl; // ��������� �������

  cout << Compare(T1, T2) << endl;
  cout << Compare(T2, T1) << endl; // ���������� � ���� ������...

  return 0;

}