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(); }
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}"); }
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); }
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(); }