Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //1st group of radio-buttons (Speaker settings):
            VoiceOutput VoiceOutput = new VoiceOutput();
            ISpeaker    Speaker     = null;

            if (IPhoneHeadset.Checked)
            {
                Speaker = new IphoneHeadset(VoiceOutput, "IphoneX", true);
            }
            else if (SamsungHeadset.Checked)
            {
                Speaker = new SamsungHeadset(VoiceOutput, "SamsungA", true);
            }
            else if (PhoneSpeaker.Checked)
            {
                Speaker = new PhoneSpeaker(VoiceOutput, "model-ABC");
            }
            else
            {
            };

            //there is an option not to select radio button without assertion error
            if (Speaker != null)
            {
                VoiceOutput.DataOutput("Speaker selected");
                Speaker.Play(null);
            }
            else
            {
                VoiceOutput.DataOutput("Speaker is not selected");
            }

            //2nd group of radio-buttons (Screen settings)
            TextOutput TextOutput = new TextOutput();
            ScreenBase Screen     = null;
            string     screenType = null;

            if (MonochromeScreen.Checked)
            {
                Screen     = new MonochromeScreen(TextOutput, 2.0, 200);
                screenType = nameof(MonochromeScreen);
            }
            else if (ColorfulScreen.Checked)
            {
                Screen     = new ColorfulScreen(TextOutput, 7.0, 500, true);
                screenType = nameof(ColorfulScreen);
            }

            //there is an option not to select radio button without assertion error
            if (Screen != null)
            {
                textBox1.Text = "Set screen to Mobile... \n Selected screen is " + screenType;
            }
            else
            {
                textBox1.Text = "Screen is not selected";
            }
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            //Select Speaker type:
            VoiceOutput VoiceOutput = new VoiceOutput();
            Dictionary <int, ISpeaker> availableSpeakers = new Dictionary <int, ISpeaker>();

            availableSpeakers.Add(1, new IphoneHeadset(VoiceOutput, "IphoneX", true));
            availableSpeakers.Add(2, new SamsungHeadset(VoiceOutput, "SamsungA", true));
            availableSpeakers.Add(3, new PhoneSpeaker(VoiceOutput, "model-ABC"));

            ISpeaker Speaker = null;

            while (Speaker == null)
            {
                Menu.ShowHeadsetMenu();

                string speakerSelected = Console.ReadLine();

                foreach (var item in availableSpeakers)
                {
                    if (speakerSelected.Equals(item.Key.ToString()))
                    {
                        Speaker = availableSpeakers[item.Key];
                        VoiceOutput.DataOutput("Speaker selected");
                        Speaker.Play(null);
                    }
                    ;
                }
                if (Speaker == null)
                {
                    VoiceOutput.DataOutput("There is no such option. Please try again");
                }
            }

            //Select the Screen type:
            TextOutput TextOutput = new TextOutput();
            Dictionary <int, ScreenBase> availableScreens = new Dictionary <int, ScreenBase>();

            availableScreens.Add(1, new MonochromeScreen(TextOutput, 300, 5));
            availableScreens.Add(2, new ColorfulScreen(TextOutput, 300, 5, false));

            ScreenBase Screen = null;

            while (Screen == null)
            {
                Menu.ShowScreenMenu();

                string screenSelected = Console.ReadLine();

                foreach (var item in availableScreens)
                {
                    if (screenSelected.Equals(item.Key.ToString()))
                    {
                        Screen = availableScreens[item.Key];
                        TextOutput.DataOutput("Set screen to Mobile... Selected screen is ");
                        Screen.DisplayInfo();
                    }
                }
                if (Screen == null)
                {
                    TextOutput.DataOutput("There is no such option. Please try again");
                }
            }

            Console.ReadLine();

            //From Lab#1:
            //ScreenBase Screen = new ColorfulScreen(7.0, 500, true);
            //IBattery Battery = new Battery(2000, "Li-ion");
            //Keyboard Keyboard = new SensorKeyboard("Russian", "Samsung");
            //Microphone Microphone = new PhoneMicrophone(94, "model-xxx0155");
            //ISpeaker Speaker = new SamsungHeadset("model-XXX", false);
            //SimCard SimCard = new MTSSimCard(SimCardType.NanoSim, 1111);
            //Mobile Samsung = new MobileSimcorp(Screen, Battery, Keyboard, Microphone, Speaker, SimCard);
            //Console.WriteLine(Samsung.GetDescription());
        }