Esempio n. 1
0
        public void BuildContainerRect_ShouldReturn_CorrectRectangle()
        {
            MyRectangle r1 = new MyRectangle(10, 10);
            MyRectangle r2 = new MyRectangle(new Point2D(-1, -8), 3, 3);
            MyRectangle r3 = MyRectangle.BuildContainerRect(r1, r2);

            bool isCorrect = r3.Peak.X == -1 && r3.Peak.Y == 0 && r3.Width == 14 && r3.Height == 14;

            Assert.IsTrue(isCorrect);
        }
Esempio n. 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));
        }