public static BeepWirelessSpeaker()
    {
        WirelessSpeaker w = new WirelessSpeaker();
        IBeepSpeakers   wirelessSpeakerBeeper =
            new IBeepSpeakers(w, s => ((WiredSpeaker)s).IsTransmitterOn = true);

        wirelessSpeakerBeeper.BeepTheSpeaker();
    }
    public static BeepWiredSpeaker()
    {
        Speaker       s = new Speaker();
        IBeepSpeakers wiredSpeakerBeeper =
            new IBeepSpeakers(s, s => ((Speaker)s).IsPlugged = true);

        wiredSpeakerBeeper.BeepTheSpeaker();
    }
 public static BeepWirelessSpeaker_Version1()
 {
     // This is a valid assignment.
     Speaker s = new WirelessSpeaker();
     IBeepSpeakers wirelessSpeakerBeeper = new IBeepSpeakers(s);
     // This call will fail!
     // In WirelessSpeaker, we _OVERRODE_ the Beep method to check
     // that TransmitterIsOn is true. But, IBeepSpeakers doesn't
     // know anything _specifically_ about WirelessSpeaker speakers,
     // so it can't set this property!
     // Therefore, an InvalidOperationException will be  thrown.
     wirelessSpeakerBeeper.BeepTheSpeaker();
 }
 // We pass in an actual speaker object.
 // This method works as expected.
 public static BeepWiredSpeaker()
 {
     Speaker s = new Speaker();
     IBeepSpeakers wiredSpeakerBeeper = new IBeepSpeakers(s);
     wiredSpeakerBeeper.BeepTheSpeaker();
 }