예제 #1
0
        static void Main(string[] args)
        {
            ///Wrong
            ///Employee but out put "i am do nothing", this is not corrected, must be "i am coding".
            ///ProjectManager is not able to substitute for Employee.
            Employee employee = new ProjectManager();
            Outputer outputer = new Outputer(employee);

            outputer.Print();

            ///Right
            ///Employee output "i am coding", this is corrected.
            Right.Employee rightEmployee = new Right.Employee();
            Right.Outputer rightOutputer = new Right.Outputer(rightEmployee);
            rightOutputer.Print();

            Console.Read();
        }
        static void Main(string[] args)
        {
            Random rng = new Random();

            IFigure[] arr = new IFigure[100];
            for (int i = 0; i < 100; i++)
            {
                if (rng.Next(0, 2) % 2 == 1)
                {
                    arr[i] = new Circle(rng.NextDouble() * rng.Next(1, 50));
                }
                else
                {
                    arr[i] = new Square(rng.NextDouble() * rng.Next(1, 50));
                }
            }
            Console.WriteLine($"Area not less than {34.5}");
            Outputer.Print(arr, 34.5);
            Console.WriteLine($"Area not less than {1}");
            Outputer.Print(arr, 1);
        }