示例#1
0
        public void BuildIntersection_SouldReturn_CorrectRectangle()
        {
            MyRectangle r1 = new MyRectangle(10, 10);
            MyRectangle r2 = new MyRectangle(new Point2D(-1, -2), 13, 13);
            MyRectangle r3 = MyRectangle.BuildIntersection(r1, r2);

            bool isCorrect = r3.Peak.X == 0 && r3.Peak.Y == -2 && r3.Width == 10 && r3.Height == 12;

            Assert.IsTrue(isCorrect);
        }
示例#2
0
        static void FunctionsDemo()
        {
            Console.WriteLine("Functions Demo");
            try
            {
                MyRectangle rect1 = new MyRectangle(new Point2D(4, 4), 4, 4);
                MyRectangle rect2 = new MyRectangle(new Point2D(3, 6), 10, 10);

                Console.WriteLine("Rectangle 2 was created with next parameters.");

                PrintfRectInfo(rect2);

                Console.WriteLine();

                Console.WriteLine("Lets get intersection of rectangle 1 and 2");

                MyRectangle rect3 = MyRectangle.BuildIntersection(rect1, rect2);

                Console.WriteLine("As a result rectangle 3 was created with next parameters.");

                PrintfRectInfo(rect3);

                Console.WriteLine();

                Console.WriteLine("Lets build container for rectangle 1 and 2");

                MyRectangle rect4 = MyRectangle.BuildContainerRect(rect1, rect2);

                Console.WriteLine("As a result rectangle 4 was created with next parameters.");

                PrintfRectInfo(rect4);
            }
            catch (Exception e)
            {
                throw e;
            }

            Console.WriteLine(new string('-', 30));
        }