Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ElectronicDevice newDevice = TvRemote.GetDevice();

            TurnTvOn onCommand = new TurnTvOn(newDevice);

            DeviceButton onPressed = new DeviceButton(onCommand);

            onPressed.Press();

            //off
            TurnTvOff ofCommand = new TurnTvOff(newDevice);

            onPressed = new DeviceButton(ofCommand);

            onPressed.Press();


            //volume
            TurnTvUp volUpCommand = new TurnTvUp(newDevice);

            onPressed = new DeviceButton(volUpCommand);

            onPressed.Press();
            onPressed.Press();
            onPressed.Press();

            //radio
            Television theTv = new Television();

            Radio theRadio = new Radio();

            List <ElectronicDevice> allDevices = new List <ElectronicDevice>();

            allDevices.Add(theTv);
            allDevices.Add(theRadio);

            TurnItAllOff turnOffDevices = new TurnItAllOff(allDevices);

            DeviceButton turnThemOff = new DeviceButton(turnOffDevices);

            turnThemOff.Press();


            //undo

            turnThemOff.PressUndo();

            Console.ReadKey();
        }
Exemplo n.º 2
0
    // Contient l'ensemble des fonctions MonoBehavior (Awake)
    #region MonoBehavior

    void Awake()
    {
        UI_Choice uiChoice = GameObject.FindWithTag("UI_Manager").GetComponent <UI_Choice>();

        if (objectName == null)
        {
            objectName = this.name;
        }

        switch (myType)
        {
        case Type.Door:
        {
            doorScript    = GetComponent <OpeningClosingDoor>();
            contactSensor = GetComponent <DDContactSensor> ();
            myState       = initialState;
            break;
        }

        case Type.Drawer:
        {
            drawerScript  = GetComponentInParent <OpeningClosingDrawer>();
            contactSensor = GetComponent <DDContactSensor> ();
            myState       = initialState;
            break;
        }

        case Type.Electronic:
        {
            electronicScript = GetComponent <ElectronicDevice>();
            myState          = initialState;
            break;
        }

        case Type.Light:
        {
            electronicScript = GetComponent <ElectronicDevice>();
            myState          = initialState;
            break;
        }

        case Type.PickUp:
        {
            characterTransform = GameObject.FindWithTag("Player").GetComponent <Transform>();
            rb      = GetComponent <Rigidbody>();
            myState = initialState;
            break;
        }
        }
    }
Exemplo n.º 3
0
Arquivo: Form1.cs Projeto: Isayur/DPR
 private void VolumeUpBtn_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex == -1)
     {
         MessageBox.Show("Select a device first");
     }
     else
     {
         ElectronicDevice temp = currentDevices[listBox1.SelectedIndex];
         if (!temp.getStatus())
         {
             MessageBox.Show("Turn on the device first");
         }
         else
         {
             TurnTVUp onCommand = new TurnTVUp(temp);
             listBox1.Items[listBox1.SelectedIndex] = onCommand.execute();
         }
     }
 }
Exemplo n.º 4
0
Arquivo: Form1.cs Projeto: Isayur/DPR
 private void TurnOffBtn_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex == -1)
     {
         MessageBox.Show("Select a device first");
     }
     else
     {
         ElectronicDevice temp = currentDevices[listBox1.SelectedIndex];
         if (!temp.getStatus())
         {
             MessageBox.Show("Device is already off");
         }
         else
         {
             TurnTVOff onCommand = new TurnTVOff(temp);
             listBox1.Items[listBox1.SelectedIndex] = onCommand.execute();
         }
     }
 }
 public TurnTvOff(ElectronicDevice newDevice)
 {
     theDevice = newDevice;
 }
Exemplo n.º 6
0
 public TurnTVOn(ElectronicDevice newDevice)
 {
     theDevice = newDevice;
 }