static void Main(string[] args) { bool RUNNING = true; Console.WriteLine("Welcome to the Account Factory Program! \n\nBy using this program, you will be able" + "to create very simple bank accounts through the selection of options provided."); // While loop for user input/account creation while (RUNNING) { Console.WriteLine("\nEnter '1' for checking, '2' for savings, '3' for retirement, or '0' to exit: "); string input = Console.ReadLine(); // Exception handling for non-integer input try { int choice = Int32.Parse(input); // Switch block to handle user input switch (choice) { case 1: var checking = AccountFactory.CreateAccount("CheckingAccount"); Console.WriteLine(string.Format("\nMessage from account management: {0}", checking.message)); break; case 2: var savings = AccountFactory.CreateAccount("SavingsAccount"); Console.WriteLine(string.Format("\nMessage from account management: {0}", savings.message)); break; case 3: var retirement = AccountFactory.CreateAccount("RetirementAccount"); Console.WriteLine(string.Format("\nMessage from account management: {0}", retirement.message)); break; case 0: RUNNING = false; Console.WriteLine("\nThank you for using the Account Factory Program! " + "\nPress 'Enter' key to exit."); Console.Read(); break; default: Console.WriteLine("Invalid Input."); break; } } catch { Console.WriteLine("Invalid Input."); } } }
static void Main(string[] args) { IAccountFactory factory = new AccountFactory(); Account account = factory.Create("Jack", 23, "King.jpg", AccountType.VIP); Tank heavyTank = new Tank(new HeavyTankFactory()); heavyTank.Weapon.Shoot(); heavyTank.Armor.Deflect(); heavyTank.Engine.Move(); Tank swagTank = new Tank(new SwagTank()); swagTank.Weapon.Shoot(); swagTank.Armor.Deflect(); swagTank.Engine.Move(); }