private static ChargerTypes ReadAndValidateChrg() { string input; int inputType; ChargerTypes chrgInpType = ChargerTypes.Car; do { input = Console.ReadLine(); } while (!Int32.TryParse(input, out inputType)); if (inputType == 1) { chrgInpType = ChargerTypes.Car; } else if (inputType == 2) { chrgInpType = ChargerTypes.Powerbk; } else if (inputType == 3) { chrgInpType = ChargerTypes.Wall; } return(chrgInpType); }
private static ChargerTypes ReadCharger(ConsoleOutput output) { output.WriteLine("Choose type of Head set to use:"); output.WriteLine($"1-{ HeadsetTypes.iPhone}"); output.WriteLine($"2-{ HeadsetTypes.Samsung}"); output.WriteLine($"3-{ HeadsetTypes.EarForceStealth}"); ChargerTypes chrgInputType = ReadAndValidateChrg(); return(chrgInputType); }
public static ICharger GetCharger(ChargerTypes chargerType) { ICharger charger = null; switch (chargerType) { case ChargerTypes.Car: { charger = new CarCharger(); break; } case ChargerTypes.Powerbk: { charger = new Powerbank(); break; } case ChargerTypes.Wall: { charger = new WallCharger(); break; } } return(charger); }
static void Main(string[] args) { ConsoleOutput outputType = new ConsoleOutput(); HeadsetTypes inputHSType = ReadHeadSet(outputType); ChargerTypes inputChrgType = ReadCharger(outputType); IPlayback headset = HeadsetFactory.GetHeadSet(outputType, inputHSType); ICharger charger = ChargerFactory.GetCharger(inputChrgType); var mymobile = new SimCorpMobile(headset, charger, outputType); Console.WriteLine(mymobile); Console.ReadKey(); }