예제 #1
0
        private static List <Shape> AskForListOfShapes()
        {
            var listOfShapes = new List <Shape>();

            while (true)
            {
                char command = ch.AskForKey("Select (T)riangle, (R)ektangle, (C)ircle or (D)one:");
                ch.Space();

                switch (command)
                {
                case 'T':
                    listOfShapes.Add(AskForTriangle());
                    break;

                case 'R':
                    listOfShapes.Add(AskForRectangle());
                    break;

                case 'C':
                    listOfShapes.Add(AskForCirle());
                    break;

                case 'D':
                    return(listOfShapes);
                }
            }
        }
        private List <Shape> AskForListOfShapes()
        {
            List <Shape> allShapes = new List <Shape>();

            while (true)
            {
                char answer = ch.AskForKey("Select (T)riangle, (R)ectangle, (C)ircle or (D)one: ");
                ch.Space();

                switch (answer.ToString().ToLower())
                {
                case "t":
                    Triangle triangle = AskForTriangle();
                    allShapes.Add(triangle);
                    break;

                case "r":
                    Rectangle rectangle = AskForRectangle();
                    allShapes.Add(rectangle);
                    break;

                case "c":
                    Circle circle = AskForCircle();
                    allShapes.Add(circle);
                    break;

                case "d":
                    return(allShapes);
                }
            }
        }