Ejemplo n.º 1
0
        static void Main()
        {
            // Create a radio and its up/down command objects
            Radio radio = new Radio();
            radio.SwitchOn();
            IVoiceCommand volumeUpCommand = new VolumeUpCommand(radio);
            IVoiceCommand volumeDownCommand = new VolumeDownCommand(radio);

            // Create an electric window and its up/down command objects
            ElectricWindow window = new ElectricWindow();
            IVoiceCommand windowUpCommand = new WindowUpCommand(window);
            IVoiceCommand windowDownCommand = new WindowDownCommand(window);

            // Create a speech recogniser object
            SpeechRecogniser speechRecogniser = new SpeechRecogniser();
            speechRecogniser.SetCommands(volumeUpCommand, volumeDownCommand);
            Console.WriteLine("Speech recognition controlling the radio");
            speechRecogniser.HearUpSpoken();
            speechRecogniser.HearUpSpoken();
            speechRecogniser.HearUpSpoken();
            speechRecogniser.HearDownSpoken();

            speechRecogniser.SetCommands(windowUpCommand, windowDownCommand);
            Console.WriteLine("Speech recognition will now control the window");
            speechRecogniser.HearDownSpoken();
            speechRecogniser.HearUpSpoken();

            Console.Read();
        }
Ejemplo n.º 2
0
 public VolumeUpCommand(Radio radio)
 {
     this.radio = radio;
 }
Ejemplo n.º 3
0
 public VolumeDownCommand(Radio radio)
 {
     this.radio = radio;
 }
Ejemplo n.º 4
0
 public VolumeUpCommand(Radio radio)
 {
     this.radio = radio;
 }
 public VolumeDownCommand(Radio radio)
 {
     this.radio = radio;
 }