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(); }
// 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; } } }
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(); } } }
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; }
public TurnTVOn(ElectronicDevice newDevice) { theDevice = newDevice; }