using System;
using System.Collections.Generic;

// Hilfsstruktur
struct Point
{
    public int X;
    public int Y;

    public Point(int x, int y)
    {
        this.X = x;
        this.Y = y;
    }
}

// Basisklasse
class Shape
{
    // Referenzpunkt zum Verschieben und Positionieren der Form
    // Das Feld ist protected, um abgeleiteten Klassen den direkten Zugriff zu erlauben
    protected Point rp = new Point();

    // Konstruktoren
    public Shape() { }
    public Shape(Point p)
    {
        rp = p;
    }
    public Shape(int x, int y)
    {
        rp.X = x;
        rp.Y = y;
    }

    // Methode zum Verschieben, wird von allen abgeleiteten Klassen genutzt
    public void Move(int dx, int dy)
    {
        rp.X += dx;
        rp.Y += dy;
    }

    // Methode zum Zeichen, wird von abgeleiteten Klassen überschrieben
    public virtual void Draw()
    {
        Console.WriteLine(" Form ({0},{1}) ", rp.X, rp.Y);
    }
}

// Abgeleitete Klassen
class Line : Shape
{
    protected Point start;
    protected Point end;

    public Line(Point s, Point e)
        : base(s)
    {
        start = s;
        end = e;
    }

    public override void Draw()
    {
        Console.WriteLine(" Linie ({0},{1}) ", rp.X, rp.Y);
    }
}

class Circle : Shape
{
    protected Point center;
    protected int radius;

    public Circle(Point p, int r)
        : base(p)
    {
        center = p;
        radius = r;
    }

    public override void Draw()
    {
        Console.WriteLine(" Kreis ({0},{1}) ", rp.X, rp.Y);
    }
}

class Polygon : Shape
{
    protected Point[] nodes;

    public Polygon(Point[] nodes)
        : base(nodes[0])
    {
        this.nodes = nodes;
    }

    public override void Draw()
    {
        Console.WriteLine(" Polygon ({0},{1}) ", rp.X, rp.Y);
    }
}

class Rectangle : Polygon
{
    public Rectangle(Point lo, Point lu, Point ro, Point ru)
        : base(new Point[4] { lo, lu, ro, ru })
    {
    }

    public override void Draw()
    {
        Console.WriteLine(" Rechteck ({0},{1}) ", rp.X, rp.Y);
    }
}

class Square : Polygon
{
    public Square(Point lo, int width)
        : base(new Point[4] {lo, 
                                      new Point(lo.X, lo.Y - width), 
                                      new Point(lo.X + width, lo.Y), 
                                      new Point(lo.X + width, lo.Y - width)})
    {
    }

    public override void Draw()
    {
        Console.WriteLine(" Quadrat ({0},{1}) ", rp.X, rp.Y);
    }
}


class Program
{
    static void Main(string[] args)
    {

        Shape[] forms = new Shape[6];

        forms[0] = new Shape(new Point(-10, 10));
        forms[1] = new Line(new Point(-10, 10), new Point(10, -10));
        forms[2] = new Circle(new Point(0, 0), 10);
        forms[3] = new Polygon(new Point[3] { new Point(10, 20), 
                                          new Point(20, 50), 
                                          new Point(30, 10) });
        forms[4] = new Rectangle(new Point(-10, 10),
                                  new Point(-10, -10),
                                  new Point(10, 10),
                                  new Point(10, -10));
        forms[5] = new Square(new Point(5, 5), 20);

        /*
        List<Shape> forms = new List<Shape>();
    
        forms.Add(new Shape(new Point(-10, 10)));
        forms.Add(new Line(new Point(-10, 10), new Point(10, -10)));
        forms.Add(new Circle(new Point(0, 0), 10));
        forms.Add(new Polygon(new Point[3] { new Point(10, 20), 
                                              new Point(20, 50), 
                                              new Point(30, 10) } ));
        forms.Add(new Rectangle( new Point(-10, 10),
                                  new Point(-10,-10),
                                  new Point(10, 10),
                                  new Point(10, -10) ));
        forms.Add(new Square(new Point(5, 5), 20));
        */

        foreach (Shape s in forms)
            s.Draw();

        Console.WriteLine("\n-------Verschieben----------\n");

        foreach (Shape s in forms)
            s.Move(25, 10);

        foreach (Shape s in forms)
            s.Draw();

    }
}
