SHARE
TWEET

Untitled

a guest Sep 21st, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class RemoteControl{
  2.   Command[] onCommands;
  3.   Command[] offCommands;
  4.  
  5.   public RemoteControl(){
  6.     onCommands = new Command[2];
  7.     offCommands = new Command[2];
  8.    
  9.     // By default set NoCommand on each button
  10.     Command noCommand = new NoCommand();
  11.     for(int i=0;i<2;i++){
  12.       onCommands[i] = noCommand;
  13.       offCommands[i] = noCommand;
  14.     }
  15.   }
  16.  
  17.   public void setCommand(int slot, Command onCommand, Command offCommand){
  18.     onCommands[slot] = onCommand;
  19.     offCommands[slot] = offCommand;
  20.   }
  21.  
  22.   public void onButtonWasPushed(int slot){
  23.     onCommands[slot].execute();
  24.   }
  25.  
  26.   public void offButtonWasPushed(int slot){
  27.     offCommands[slot].execute();
  28.   }
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top