static void Main(string[] args) { AutomobileFactory factory = new AutomobileFactory(); Console.WriteLine("case 1"); IAutomobile audi = factory.make(AutomobileType.Audi); audi.start(); audi.stop(); IAutomobile bmw = factory.make(AutomobileType.BMW); bmw.start(); bmw.stop(); Console.WriteLine("\ncase 2"); IAutomobile unspecified = factory.make(AutomobileType.Unspecified); //unspecified.start(); //unspecified.stop(); Console.WriteLine("\ncase 3"); AutomobileFactory factory1 = new AutomobileFactory(); IAutomobile tesla = factory1.make(AutomobileType.Tesla); tesla.start(); tesla.stop(); }
static void Main(string[] args) { //Ask the user for the phone they wish to create Console.WriteLine("What kind of Vehicle do You desire Sir/Madam?"); string userPhone = Console.ReadLine(); //Choose the correct type of phone to create through the factory method that implements the ICallable interface ICallable phone = AutomobileFactory.GetCar(userPhone); phone.Build(); Console.ReadLine(); //***********Example of bad practice************// //Console.WriteLine("What kind of phone do you want to create?"); //string userPhone = Console.ReadLine(); //if (userPhone.ToLower() == "android") //{ // AndroidPhone android = new AndroidPhone(); // android.Build(); // Console.ReadLine(); //} //else if (userPhone.ToLower() == "apple") //{ // ApplePhone apple = new ApplePhone(); // apple.Build(); // Console.ReadLine(); //} //else if (userPhone.ToLower() == "iphone") //{ // ApplePhone apple = new ApplePhone(); // apple.Build(); // Console.ReadLine(); //} //else if (userPhone.ToLower() == "google") //{ // GooglePhone google = new GooglePhone(); // google.Build(); // Console.ReadLine(); //} //else //{ // AndroidPhone android = new AndroidPhone(); // android.Build(); // Console.ReadLine(); //} }