Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public Rectangle(Rectangle original)
 {
     this.a = original.a;
     this.b = original.b;
     this.c = original.c;
     this.d = original.d;
 }
Esempio n. 3
0
 public Rectangle(Rectangle rect)
 {
     rect.A = A;
     rect.B = B;
     rect.C = C;
     rect.D = D;
 }
Esempio n. 4
0
        public Rectangle(Rectangle rectangle)
        {
            Point first = rectangle.lowerLeftPoint;
            Point second = rectangle.upperRightPoint;

            if (first.GetY > second.GetY)
            {
            //Reverse points to avoid exceptions

                Point tempPoint = first;
                first = second;
                second = tempPoint;
            }

            this.width = second.GetX - first.GetX;
            this.height = second.GetY - first.GetY;

            this.lowerLeftPoint = first;
            this.upperLeftPoint = new Point(first.GetX, second.GetY - this.width);
            this.upperRightPoint = second;
            this.lowerRightPoint = new Point(second.GetX, first.GetY + this.width);

            this.upperSide = new LineSegment(this.upperLeftPoint, this.upperRightPoint);
            this.lowerSide = new LineSegment(this.lowerLeftPoint, this.lowerRightPoint);
            this.leftSide = new LineSegment(this.lowerLeftPoint, this.upperLeftPoint);
            this.rightSide = new LineSegment(this.lowerRightPoint, this.upperRightPoint);

            this.center = new Point(first.GetX + this.width / 2, first.GetY + this.height / 2);
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            //Point newPoint = new Point(-1, 1);
            //Point newerPoint = new Point(3, 4);
            //LineSegment ls = new LineSegment(newPoint, newerPoint);
            //LineSegment lsTwo = new LineSegment(new Point(-1, 2), new Point(3, 4));
            //Console.WriteLine(ls.Equals(lsTwo));

            Rectangle rec = new Rectangle(new Point(1, 1), new Point(5, 6));
        }
 public void GetPerimeterTest78()
 {
     Rectangle rectangle;
     double d;
     Point s0 = new Point(2, 2, 0, 0);
     Point s1 = new Point(0, 0, 0, 0);
     rectangle = new Rectangle(s0, s1);
     d = this.GetPerimeterTest(rectangle);
     Assert.AreEqual<double>(8, d);
     Assert.IsNotNull((object)rectangle);
 }
 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));
 }
Esempio n. 8
0
 public Rectangle(Rectangle rect)
 {
     lowerLeftPoint = new Point(rect.lowerLeftPoint.X, rect.lowerLeftPoint.Y);
     lowerRightPoint = new Point(rect.lowerRightPoint.X, rect.lowerRightPoint.Y);
     upperLeftPoint = new Point(rect.upperLeftPoint.X, rect.upperLeftPoint.Y);
     upperRightPoint = new Point(rect.upperRightPoint.X, rect.upperRightPoint.Y);
     lowerSide = new LineSegment(rect.lowerSide.StartPoint, rect.lowerSide.EndPoint);
     upperSide = new LineSegment(rect.upperSide.StartPoint, rect.upperSide.EndPoint);
     leftSide = new LineSegment(rect.leftSide.StartPoint, rect.leftSide.EndPoint);
     rightSide = new LineSegment(rect.rightSide.StartPoint, rect.rightSide.EndPoint);
     width = rect.width;
     height = rect.height;
     center = new Point(rect.center.X, rect.center.Y);
 }
 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();
 }
Esempio n. 10
0
        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();
        }
Esempio n. 11
0
 static void Main(string[] args)
 {
     Point point = new Point(1, 1);
     Point point1 = new Point(7, 3);
     Point point2 = new Point(1, 1);
     Point point3 = new Point(7, 3);
     //LineSegment line = new LineSegment(point, point3);
     //LineSegment line1 = new LineSegment(point1, point2);
     //Console.WriteLine(line != line1);
     //Console.WriteLine(line <= line1);
     Rectangle rect = new Rectangle(point, point1);
     Rectangle newRect = new Rectangle(point2, point3);
     Console.WriteLine("Rectangle Parameter = {0}", rect.GetParameter());
     Console.WriteLine("Rectangle Area = {0}",rect.GetArea());
     Console.WriteLine(rect.ToString());
     Console.WriteLine(rect.Equals(newRect));
     //Console.WriteLine(rect == newRect);
 }
Esempio n. 12
0
        /// <summary>
        /// Main Method.
        /// </summary>
        public static void Main()
        {
            Point point = new Point(0, 0);
            Point point2 = new Point(4, 4);

            Point point3 = new Point(5, 5);
            Point point4 = new Point(1, 1);

            LineSegment line = new LineSegment(point, point2);
            LineSegment line2 = new LineSegment(point3, point4);

            Rectangle rect = new Rectangle(point, point2);
            Rectangle rect2 = new Rectangle(point3, point4);

            // TODO : properties for edges;
            Vector vect1 = new Vector(1, 2, 3);
            Vector vect2 = new Vector(4, 5, 6);
            Console.WriteLine(vect1 * vect2);
        }
Esempio n. 13
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();
        }
Esempio n. 14
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));
        }
Esempio n. 15
0
 public Rectangle ( Rectangle r ) : this(r.VertexA , r.VertexC) { }
Esempio n. 16
0
 public Rectangle(Rectangle rec)
 {
     Rectangle rec1 = new Rectangle(rec.vert1, rec.vert2);
 }
 /// <summary>
 /// Equals method for current instance and another Rectangle object.
 /// </summary>
 /// <param name="other">Rectangle object.</param>
 /// <returns>True if both objects are equal.</returns>
 protected bool Equals(Rectangle other)
 {
     return Rectangle.Equals(this.PointA, other.PointA)
         && Rectangle.Equals(this.PointB, other.PointB)
         && Rectangle.Equals(this.PointC, other.PointC)
         && Rectangle.Equals(this.PointD, other.PointD)
         && Rectangle.Equals(this.ab, other.ab)
         && Rectangle.Equals(this.bc, other.bc);
 }
Esempio n. 18
0
 public static int getPerimeter(Rectangle rec)
 {
     return (rec.Ab.GetLength() * 2) + (rec.Bc.GetLength() * 2);
 }
Esempio n. 19
0
 public static int getArea(Rectangle rec)
 {
     return rec.Ab.GetLength() * rec.Bc.GetLength();
 }