예제 #1
0
        static void Main(string[] args)
        {
            var s2d    = new Shape2D(3, 4);
            var square = new Square(3);
            var s3d    = new Shape3D(3, 4, 5);


            s3d.Volume();
        }
예제 #2
0
        /********************************************
        * TODO 08: Create method to "Get total area"
        *       private MenuOptionResult ShowTotalArea()
        *   and report it to the user
        ********************************************/
        public MenuOptionResult GetTotalArea()
        {
            int totalArea = 0;

            foreach (IDrawable drawable in this.drawables)
            {
                if (drawable is Shape2D)
                {
                    Shape2D shape = (Shape2D)drawable;
                    totalArea += shape.Area;
                }
            }
            Console.WriteLine($"Total Area: {totalArea}");
            return(MenuOptionResult.WaitAfterMenuSelection);
        }
예제 #3
0
        /********************************************
        * Method to "Get total area"
        *       private MenuOptionResult ShowTotalArea()
        *   and report it to the user
        ********************************************/
        private MenuOptionResult ShowTotalArea()
        {
            int totalArea = 0;

            foreach (IDrawable drawable in drawableThings)
            {
                if (drawable is Shape2D)
                {
                    Shape2D shape = (Shape2D)drawable;
                    totalArea += shape.Area;
                }
            }
            Console.WriteLine($"Total area of all shapes is {totalArea}.");

            return(MenuOptionResult.WaitAfterMenuSelection);
        }