Пример #1
0
        private static void TryAdapter2(KoreanWallOutlet outlet, AmericanPlug americanPlug)
        {
            var adapter2 = new RegulatedAdapter(americanPlug);

            outlet.PlugIn(adapter2);
            var powerApplied = outlet.ApplyPower();

            if (powerApplied)
            {
                Console.WriteLine("Used regulated adapter Device turned on.");
            }
        }
Пример #2
0
        private static void TryKoreanPlug(KoreanWallOutlet outlet)
        {
            var koreanPlug = new KoreanPlug();

            outlet.PlugIn(koreanPlug);
            var powerApplied = outlet.ApplyPower();

            if (powerApplied)
            {
                Console.WriteLine("Used Korean Plug. Device turned on.");
            }
        }
Пример #3
0
 private static void TryAdapter1(KoreanWallOutlet outlet, AmericanPlug americanPlug)
 {
     try
     {
         // the voltages don't match so this won't work either
         var adapter1 = new UnregulatedAdapter(americanPlug);
         outlet.PlugIn(adapter1);
         outlet.ApplyPower(); // boom
     }
     catch (Exception ex)
     {
         Console.WriteLine($"Used unregulated adapter. {ex.Message}");
     }
 }