Beispiel #1
0
        static void Main(string[] args)
        {
            ShapeObjectFactory sof = new ShapeObjectFactory();

            IShape shape = sof.GetShape("Triangle");

            shape.Print();
            shape = sof.GetShape("Triangle");
            shape.Print();
            shape = sof.GetShape("Triangle");
            shape.Print();

            shape = sof.GetShape("Square");
            shape.Print();
            shape = sof.GetShape("Square");
            shape.Print();
            shape = sof.GetShape("Square");
            shape.Print();

            //shape = sof.GetShape("Circle"); //Exception
            //shape.Print();

            int total = sof.TotalObjectsCreated;

            Console.WriteLine($"\n Number of objects created = {total}");

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            ShapeObjectFactory sof   = new ShapeObjectFactory();
            IShape             shape = sof.GetShape("Rectangle");

            shape.Print();

            shape = sof.GetShape("Rectangle");
            shape.Print();

            shape = sof.GetShape("Circle");
            shape.Print();

            shape = sof.GetShape("Circle");
            shape.Print();

            shape = sof.GetShape("Rectangle");
            shape.Print();
        }
Beispiel #3
0
        public static void Main()
        {
            ShapeObjectFactory sof = new ShapeObjectFactory();

            IShape shape = sof.GetShape("Triangle");

            shape.Print();
            shape = sof.GetShape("Triangle");
            shape.Print();
            shape = sof.GetShape("Triangle");
            shape.Print();

            shape = sof.GetShape("Square");
            shape.Print();
            shape = sof.GetShape("Square");
            shape.Print();
            shape = sof.GetShape("Square");
            shape.Print();

            int total = sof.TotalObjectsCreated;

            Console.WriteLine($"{Environment.NewLine} Number of objects created = {total}");
        }
Beispiel #4
0
        public void Main()
        {
            ShapeObjectFactory sof = ShapeObjectFactory.Instance;

            IShape shape = sof.GetShape("Rectangle");

            shape.Print(ConsoleColor.White);
            shape = sof.GetShape("Rectangle");
            shape.Print(ConsoleColor.Blue);
            shape = sof.GetShape("Rectangle");
            shape.Print(ConsoleColor.Cyan);

            shape = sof.GetShape("Circle");
            shape.Print(ConsoleColor.DarkBlue);
            shape = sof.GetShape("Circle");
            shape.Print(ConsoleColor.DarkMagenta);
            shape = sof.GetShape("Circle");
            shape.Print(ConsoleColor.White);

            int numObjects = sof.TotalObjectsCreated;

            Console.WriteLine("\nTotal No of Objects created = {0}", numObjects);
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            ShapeObjectFactory sof = new ShapeObjectFactory();

            IShape shape = sof.GetShape("Rectangle");

            shape.Print();
            shape = sof.GetShape("Rectangle");
            shape.Print();
            shape = sof.GetShape("Rectangle");
            shape.Print();

            shape = sof.GetShape("Circle");
            shape.Print();
            shape = sof.GetShape("Circle");
            shape.Print();
            shape = sof.GetShape("Circle");
            shape.Print();

            int NumObjs = sof.TotalObjectsCreated;

            Console.WriteLine("\nTotal No of Objects created = {0}", NumObjs);
            Console.ReadKey();
        }