using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Geometrie
{
    class Program
    {
        static void Main(string[] args)
        {
            EnhancedPoint P1 = new EnhancedPoint(1, 3);
            EnhancedPoint P2 = new EnhancedPoint(P1);
            EnhancedPoint P3 = P1 + P2;
            EnhancedPoint P4 = P3 - P1;
            Console.WriteLine("P1: " + P1);
            Console.WriteLine("P2: " + P2);
            Console.WriteLine("P3 = P1 + P2: " + P3);
            Console.WriteLine("P4 = P3 - P1: " + P4);
            Console.WriteLine("P1 == P3: " + (P1 == P3));
            Console.WriteLine("P1 == P2: " + (P1 == P2));
            Console.WriteLine("Entfernung von P1 und P3: " + EnhancedPoint.Entfernung(P1, P3));
            Console.WriteLine("Entfernung von P3 vom Ursprung: " + (float)P3);
            Console.ReadLine();
        }
    }

    class Point
    {
        public int X;
        public int Y;
    }

    class EnhancedPoint : Point
    {
        public EnhancedPoint() : this(0,0) {}

        public EnhancedPoint(Point punkt) : this(punkt.X,punkt.Y) {}

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

        public override string ToString()
        {
            return "(" + X + "," + Y + ")";
        }

        public static EnhancedPoint operator +(EnhancedPoint p1, EnhancedPoint p2)
        {
            return new EnhancedPoint(p1.X + p2.X, p1.Y + p2.Y);
        }

        public static EnhancedPoint operator -(EnhancedPoint p1, EnhancedPoint p2)
        {
            return new EnhancedPoint(p1.X - p2.X, p1.Y - p2.Y);
        }

        public static bool operator ==(EnhancedPoint p1, EnhancedPoint p2)
        {
            return p1.X == p2.X && p1.Y == p2.Y;
        }

        public static bool operator !=(EnhancedPoint p1, EnhancedPoint p2)
        {
            return !(p1 == p2);
        }

        public static double Entfernung(EnhancedPoint p1, EnhancedPoint p2)
        {
            return Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2));
        }

        public static explicit operator float(EnhancedPoint p1)
        {
            return (float)Math.Sqrt((p1.X * p1.X) + (p1.Y * p1.Y));
        }
    }
}
