static void Main(string[] args)
        {
            Point p3 = new Point(7, 7);
            Point p4 = new Point(0, 0);
            //Console.WriteLine(p1.Equals(p2));
            //p1.Equals(p2);

            //Console.WriteLine(p1.Equals(p2));
            //Console.WriteLine(p1.Equals(p3));
            //Console.WriteLine(p1 != p2);
            //Console.WriteLine(p1 != p3);

            //// LineSegment ls3 = new LineSegment(p1, p1);
            //Console.WriteLine(ls1.GetLength());
            //Console.WriteLine(ls1.ToString());
            //Console.WriteLine(ls2.Equals(ls1));
            //Console.WriteLine(ls1 == ls2);
            //Console.WriteLine(ls1 != ls2);
            //Console.WriteLine(ls1 >= 5.00f);
            //Console.WriteLine(ls1 <= 4.00f);
            Point p1 = new Point();
            Point p2 = new Point(4, 4);
            Rectangle a = new Rectangle(p1,p2);
            Console.WriteLine(a.GetArea());
            Console.WriteLine(a.GetPerimeter());
            Console.WriteLine(a.Down + " " + a.Center + " " + a.Up + " " + a.Left + " " +a.Right);
        }
 static void Main(string[] args)
 {
     Point pointA = new Point(3, 4);
     Point pointB = new Point(6, 8);
     Point pointC = new Point(3, 4);
     Point pointD = new Point(6, 8);
     Rectangle firstRectangle = new Rectangle(pointA, pointB);
     Rectangle secondRectangle = new Rectangle(pointC, pointD);
     Console.WriteLine("Rectangle area is: {0}",firstRectangle.GetArea());
     Console.WriteLine("Rectang;e perimeter is: {0}",firstRectangle.GetPerimeter());
     Console.WriteLine(firstRectangle.ToString());
     Console.WriteLine(firstRectangle.Equals(secondRectangle));
 }
 static void Main ( string[] args )
 {
     Point a = new Point(1 , 1);
     Point c = new Point(4 , 2);
     Rectangle r = new Rectangle(a , c);
     Console.WriteLine(a);
     Console.WriteLine(c);
     Console.WriteLine(r);
     Console.WriteLine(r.Center);
     Console.WriteLine("Edges: {0} \n {1} \n  {2} \n   {3}" , r.AB , r.BC , r.BD , r.DA);
     Console.WriteLine(r.GetArea());
     Console.WriteLine(r.GetPerimeter());
     Console.WriteLine(r.GetHashCode());
     Console.WriteLine("Read any key...");
     Console.ReadKey();
 }
        static void Main(string[] args)
        {
            Point p1 = new Point(1.2, 2.1);
            Point p2 = new Point(5.4, 7.2);

            Console.WriteLine("{0} + {1} = {2}", p1, p2, p1 + p2);

            Console.WriteLine();

            LineSegment ls1 = new LineSegment(new Point(1, 1), new Point(1, 5));
            LineSegment ls2 = new LineSegment(new Point(2, 3), new Point(4, 5));

            Console.WriteLine("{0} -> Length: {1}", ls1, ls1.GetLength());
            Console.WriteLine("{0} -> Length: {1}", ls2, ls2.GetLength());

            Console.WriteLine();

            Rectangle rect = new Rectangle(p1, p2);
            Rectangle rect2 = new Rectangle(p2, p1);

            Console.WriteLine("Is {0} equal to {1} -> {2}", rect, rect2, rect.Equals(rect2));
            Console.WriteLine();
            Console.WriteLine("Rectangle from {0} and {1} has these properties:", p1, p2);
            Console.WriteLine("Width: {0}", rect.Width);
            Console.WriteLine("Height: {0}", rect.Height);
            Console.WriteLine("Lower Left: {0}", rect.LowerLeftPoint);
            Console.WriteLine("Lower Rigth: {0}", rect.LowerRightPoint);
            Console.WriteLine("Upper Left: {0}", rect.UpperLeftPoint);
            Console.WriteLine("Upper Rigth: {0}", rect.UpperRightPoint);
            Console.WriteLine("Perimeter: {0}", rect.GetPerimeter());
            Console.WriteLine("Area: {0}", rect.GetArea());
            Console.WriteLine("Center: {0}", rect.Center);

            Console.WriteLine();

            Vector v1 = new Vector(1, 2, 3, 4);
            Vector v2 = new Vector(7, 3, 8, 1);

            Console.WriteLine("{0} + {1} = {2}", v1, v2, v1 + v2);
            Console.WriteLine("{0} - {1} = {2}", v1, v2, v1 - v2);
            Console.WriteLine("{0} * {1} = {2}", v1, v2, v1 * v2);
            Console.WriteLine("{0} - {1} = {2}", v1, 0.2, v1 - 0.2);
            Console.WriteLine("{0} * {1} = {2}", v1, 0.2, v1 * 0.2);

            Console.ReadKey();
        }
Exemple #5
0
        static void Main(string[] args)
        {
            Point firstPoint = new Point(5, 5);
            Point secondPoint = new Point(7, 7);

            LineSegment first = new LineSegment(firstPoint, secondPoint);
            LineSegment second = new LineSegment(firstPoint, secondPoint);

            Console.WriteLine(first > second);
            Console.WriteLine(first >= second);
            Console.WriteLine(first == second);

            LineSegment twoPoints = firstPoint + secondPoint;

            Rectangle rect = new Rectangle(firstPoint, secondPoint);
            Rectangle anotherRect = new Rectangle(secondPoint, firstPoint);

            Console.WriteLine("Equals: " + rect.Equals(anotherRect));
            Console.WriteLine();
            Console.WriteLine("Width: {0}", rect.GetWidth);
            Console.WriteLine("Height: {0}", rect.GetHeight);
            Console.WriteLine("Lower Left: {0}", rect.GetLowerLeftPoint);
            Console.WriteLine("Lower Rigth: {0}", rect.GetLowerRightPoint);
            Console.WriteLine("Upper Left: {0}", rect.GetUpperLeftPoint);
            Console.WriteLine("Upper Rigth: {0}", rect.GetUpperRightPoint);
            Console.WriteLine("Perimeter: {0}", rect.GetPerimeter());
            Console.WriteLine("Area: {0}", rect.GetArea());
            Console.WriteLine("Center: {0}", rect.GetCenterPoint);
            Console.WriteLine();

            Vector vector = new Vector(new double[] { 1, 2, 3, 4 });
            Vector anotherVector = new Vector(new double[] { 5, 6, 7, 8, 9 });

            Console.WriteLine("{0} + {1} = {2}", vector, anotherVector, vector + anotherVector);
            Console.WriteLine("{0} - {1} = {2}", vector, anotherVector, vector - anotherVector);
            Console.WriteLine("{0} * {1} = {2}", vector, anotherVector, vector * anotherVector);
            double scalar = 0.7;
            Console.WriteLine("{0} - {1} = {2}", vector, scalar, vector - scalar);
            Console.WriteLine("{0} * {1} = {2}", vector, scalar, vector * scalar);
            Console.WriteLine();
        }
Exemple #6
0
        static void TestGeometry()
        {
            Rectangle rect1 = new Rectangle(new Point(0, 0), new Point(3, 3));
            Rectangle rect2 = new Rectangle(new Point(6, 6), new Point(-3, 3));

            Console.WriteLine(rect1.ToString());
            Console.WriteLine(rect1.GetPerimeter());
            Console.WriteLine(rect1.GetArea());
            Console.WriteLine(rect1.Bottom);
            Console.WriteLine(rect1.Center);
            Console.WriteLine(rect1.DownLeft);
            Console.WriteLine(rect1.DownRight);
            Console.WriteLine(rect1.Height);
            Console.WriteLine(rect1.Width);
            Console.WriteLine(rect1.Left);
            Console.WriteLine(rect1.Right);
            Console.WriteLine(rect1.Top);
            Console.WriteLine(rect1.UpLeft);
            Console.WriteLine(rect1.UpRight);

            Console.WriteLine(rect2.ToString());
            Console.WriteLine(rect2.GetPerimeter());
            Console.WriteLine(rect2.GetArea());
            Console.WriteLine(rect2.Bottom);
            Console.WriteLine(rect2.Center);
            Console.WriteLine(rect2.DownLeft);
            Console.WriteLine(rect2.DownRight);
            Console.WriteLine(rect2.Height);
            Console.WriteLine(rect2.Width);
            Console.WriteLine(rect2.Left);
            Console.WriteLine(rect2.Right);
            Console.WriteLine(rect2.Top);
            Console.WriteLine(rect2.UpLeft);
            Console.WriteLine(rect2.UpRight);

            Console.WriteLine(rect1.Equals(rect2));
        }