Esempio n. 1
0
        public void ConfigureMobile()
        {
            Console.WriteLine("Select playback component (specify index):");
            Console.WriteLine($"1 - {nameof(iPhoneHeadset)}");
            Console.WriteLine($"2 - {nameof(SamsungHeadset)}");
            Console.WriteLine($"3 - {nameof(UnoffocoaliPhoneHeadset)}");
            Console.WriteLine($"4 - {nameof(PhoneSpeaker)}");

            int type = Convert.ToInt32(Console.ReadLine());

            PlaybackComponent = HeadsetFactory.GetPlayback(type);
            PlaybackComponent.Play(new object());

            Console.WriteLine("Select SimCard (specify index):");
            Console.WriteLine($"1 - {nameof(NanoSim)}");
            Console.WriteLine($"2 - {nameof(MicroSim)}");
            Console.WriteLine($"3 - {nameof(MiniSim)}");
            Console.WriteLine($"4 - {nameof(Sim)}");

            type        = Convert.ToInt32(Console.ReadLine());
            SimCardItem = SimCardFactory.GetSimCard(type);
            SimCardItem.Call(new object());

            Console.WriteLine("Select charger (specify index):");
            Console.WriteLine($"1 - {nameof(SamsungCharger)}");
            Console.WriteLine($"2 - {nameof(SonyCharger)}");
            Console.WriteLine($"3 - {nameof(NokiaCharger)}");
            Console.WriteLine($"4 - {nameof(MotoCharger)}");

            type = Convert.ToInt32(Console.ReadLine());
            ChargerComponenet = ChargerFactory.GetCharger(type);
            ChargerComponenet.Charge(new object());

            Console.ReadKey();
        }
Esempio n. 2
0
 private void ChooseChargerButton_Click(object sender, EventArgs e)
 {
     if (Charger == null)
     {
         MessageBox.Show("Please choose one of the option", "Info", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
     else
     {
         ChargeTextBox.Text = $"{Charger.GetType().Name} selected\r\n";
         Charger.Charge();
     }
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            SimcorpMobile Phone = new SimcorpMobile();

            Console.WriteLine(Phone);

            IPlayback playbackComponent = GetPlaybackComponent();

            Console.WriteLine($" {playbackComponent} selected");
            Console.WriteLine(" Set playback to Mobile ...");
            Console.WriteLine(" Play sound in Mobile:");
            playbackComponent.Play(new object());

            ICharger chargingDevice = GetChargingDevice();

            chargingDevice.Charge(Phone.Battery);
            Console.ReadKey();
        }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            var mobile = new ModernMobile(output);

            while (true)
            {
                Console.WriteLine("\n============================");
                Console.WriteLine("Select device: (Esc to exit)");
                Console.WriteLine($"{DEVICE_HEADPHONES} - Headphones");
                Console.WriteLine($"{DEVICE_CHARGER} - Charger");

                ConsoleKeyInfo userInput = ReadKeyRestricted();
                Console.WriteLine();
                if (userInput.Key == ConsoleKey.Escape)
                {
                    if (!ConfirmationPopup("You are going to exit."))
                    {
                        continue;
                    }
                    return;
                }

                switch (userInput.KeyChar)
                {
                case DEVICE_HEADPHONES:
                    AbstractCreator <IPlayback> playbackCreator = playbackCreators[ChooseCreator("Choose playback:", playbackCreators)];
                    mobile.PlaybackComponent = playbackCreator.Creator.Invoke();

                    mobile.Play(new object());
                    break;

                case DEVICE_CHARGER:
                    AbstractCreator <ICharger> chargerCreator = chargerCreators[ChooseCreator("Choose charger:", chargerCreators)];
                    ICharger charger = chargerCreator.Creator.Invoke();

                    charger?.Charge(mobile);
                    break;

                default:
                    Console.WriteLine("Unexpected input. Please try again.");
                    continue;
                }
            }
        }
Esempio n. 5
0
        public string Charge()
        {
            var chargeMessage = chargingCable.Charge();

            return(chargeMessage);
        }
Esempio n. 6
0
 public void Charge()
 {
     ChargerComponent.Charge();
 }
Esempio n. 7
0
 public void Charge(ICharger ChargerComponent)
 {
     ChargerComponent.Charge(Battery);
 }
Esempio n. 8
0
 public void Charge(ICharger charger)
 {
     Charger = charger;
     Charger?.Charge(this);
 }