/// <summary> /// Selling the items. /// </summary> public void SellingItems() { ITarget2 target2 = new VendorAdapter(); foreach (string items in target2.GetProducts()) { Console.WriteLine(items); } }
/// <summary> /// Defines the entry point of the application. /// </summary> /// <param name="args">The arguments.</param> public static void Main(string[] args) { try { char ch = '\x0000'; int choice = 0; ////starting do while iteration do { Console.WriteLine("Enter 1 to execute First singleton program"); Console.WriteLine("Enter 2 to execute Factory design Progrm"); Console.WriteLine("Enter 3 to execute Adapter design Pattern Program"); Console.WriteLine("Enter 4 to execute shoping portal client done with Adapter design Pattern"); Console.WriteLine("Enter 5 to execute Car creation which is done using Facade design Pattern"); Console.WriteLine("Enter 6 to exceute shape of polygon class done using Proxy design Patterns"); Console.WriteLine("Enter 7 to execute Subscribe/Unsubscribe product from shooping site using Observer Design Pattern"); Console.WriteLine("Enter 8 to Execute store/visitor program using Visitor Design Pattern"); Console.WriteLine("Enter 9 to execute chatRoom program using Mediator design Patterns"); Console.WriteLine("Enter 10 to execute restaurant/veg market using Observer Design Pattern"); Console.WriteLine("Enter 11 to execute Reflection"); try { choice = Convert.ToInt32(Console.ReadLine()); } catch (Exception e) { Console.WriteLine("Only number is accepted " + e.Message); } ////switch case to take to your desired class switch (choice) { case 1: SingletonEx fromStudent = SingletonEx.GetInstance; fromStudent.Execution(); break; case 2: ConcreteVehicleFactory concreteVehicleFactory = new ConcreteVehicleFactory(); concreteVehicleFactory.Runner(); break; case 3: EmployeeAdapter employeeAdapter = new EmployeeAdapter(); employeeAdapter.BillingRunner(); break; case 4: VendorAdapter vendorAdapter = new VendorAdapter(); vendorAdapter.SellingItems(); break; case 5: CarFacade carFacade = new CarFacade(); carFacade.CreateCompleteCar(); break; case 6: ProxyPolygon proxyPolygon = new ProxyPolygon(); proxyPolygon.ProxyRunner(); break; case 7: Product.RunnerObserver(); break; case 8: VisitorRunner visitorRunner = new VisitorRunner(); visitorRunner.Runner(); break; case 9: MediatorRunner mediatorRunner = new MediatorRunner(); mediatorRunner.Runner(); break; case 10: VeggiesRunner veggiesRunner = new VeggiesRunner(); veggiesRunner.Runner(); break; case 11: EmployeeReflection employeeReflection = new EmployeeReflection(); employeeReflection.Reflection(); break; default: Console.WriteLine("Enter number in range only"); break; } Console.WriteLine("Do you want to execute more programs(y/n)"); try { ch = Convert.ToChar(Console.ReadLine()); } catch (SystemException e) { Console.WriteLine(e.Message); } }while (ch != 'n'); } catch (Exception e) { Console.WriteLine(e.Message); } }
/// <summary> /// Defines the entry point of the application. /// </summary> /// <param name="args">The arguments.</param> /// <exception cref="Exception">system exception </exception> public static void Main(string[] args) { try { ////this variable is used for do condtion string doCondition = null; ////this variable is used for switch case int switchCases = 0; do { Console.WriteLine("enter 1 for singleton pattern"); Console.WriteLine("enter 2 for factory design patten"); Console.WriteLine("enter 3 for adaptor design pattern"); Console.WriteLine("enter 4 for proxy design pattern"); Console.WriteLine("enter 5 for facade design pattern"); Console.WriteLine("enter 6 for mediator design pattern"); Console.WriteLine("enter 7 for observer 1 designer pattern"); Console.WriteLine("enter 8 for observer 2 designer pattern"); Console.WriteLine("enter 9 for visitor design pattern"); Console.WriteLine("enter 10 for adaptor2 design patten"); Console.WriteLine("enter 11 for Reflection"); Console.WriteLine("enter 12 for Annotation program"); try { switchCases = Convert.ToInt32(Console.ReadLine()); } catch (Exception) { Console.WriteLine("enter valid number only"); } switch (switchCases) { case 1: SingletonPattern reference1 = SingletonPattern.GetInstance; reference1.Message("hi how are you"); SingletonPattern reference2 = SingletonPattern.GetInstance; reference2.Message("manju"); Console.ReadLine(); break; case 2: EmployeeFactory employeeFactory = new ConcreteEmployeeFactory(); IFactory permanentEmployee = employeeFactory.Factory("PermanentEmployee"); permanentEmployee.Details(); IFactory temporaryEmployee = employeeFactory.Factory("TemporaryEmployee"); temporaryEmployee.Details(); Console.ReadLine(); break; case 3: ITarget itarget = new EmployeeAdapator(); ThirdPartyBillingSystem client = new ThirdPartyBillingSystem(itarget); client.ShowEmployeeList(); break; case 4: ProxyClient proxyClient = new ProxyClient(); Console.WriteLine("Data from Proxy Client = {0}", proxyClient.GetData()); break; case 5: HomeFacade homeFacade = new HomeFacade(); homeFacade.LeaveHome(); homeFacade.ArriveHome(); break; case 6: MediatorMainClass mediator = new MediatorMainClass(); mediator.Mediator(); break; case 7: ObserverClass observerClass = new ObserverClass(); observerClass.Observer(); break; case 8: ObserverRealTime realTime = new ObserverRealTime(); realTime.ObserverRealTimeExample(); break; case 9: VisitorRunner visitorRunner = new VisitorRunner(); visitorRunner.Runner(); break; case 10: VendorAdapter vendorAdapter = new VendorAdapter(); vendorAdapter.SellingItems(); break; case 11: ExampleOfReflection exampleOfReflection = new ExampleOfReflection(); exampleOfReflection.ReflectionImplementation(); break; case 12: AnnotationPrograms annotationPrograms = new AnnotationPrograms(); annotationPrograms.ValidationOfAnnotation(); break; } Console.WriteLine("enter y to go to main method or enter any key to stop execution"); doCondition = Console.ReadLine(); }while (doCondition.Equals("y")); } catch (Exception e) { throw new Exception(e.Message); } }