Exemplo n.º 1
0
        public static Shape GetShape(int type, Random random)
        {
            Shape shape;

            switch (type)
            {
            case 0:
                shape = new Rectangle(random.Next(1, 10), random.Next(1, 10));
                break;

            case 1:
                shape = new Square(random.Next(1, 10));
                break;

            default:
                shape = new Triangle(random.Next(1, 10), random.Next(1, 10));
                break;
            }
            Console.WriteLine(shape.GetType().Name + ":" + shape.Area());
            return(shape);
        }