Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.68 KB | None | 0 0
  1. import java.awt.event.*;
  2. import java.awt.*;
  3. public class GestorePulsanti implements ActionListener
  4. {
  5.   private Automobile auto;
  6.   private TextField txEng;
  7.   private TextField txSpe;
  8.   private TextField txGear;
  9.   public GestorePulsanti(Automobile a,TextField te,TextField ts,TextField tg)
  10.   {
  11.         auto=a;
  12.         txEng=te;
  13.         txSpe=ts;
  14.         txGear=tg;
  15.   }
  16.     public void actionPerformed(ActionEvent e)
  17.     {
  18.       String bottone=e.getActionCommand();
  19.       switch(bottone)
  20.       {
  21.           case ("Start"):
  22.           {
  23.                if(txEng.getText().equals("OFF"))
  24.                {
  25.                   auto.accendi();
  26.                   txEng.setText(null);
  27.                   txEng.setText(auto.getMotore());
  28.                }
  29.                break;
  30.           }
  31.         case ("Stop"):
  32.       {
  33.               if(txEng.getText().equals("ON"))
  34.               {
  35.                   auto.spegni();
  36.                   txEng.setText(null);
  37.                   txEng.setText(auto.getMotore());
  38.                   txSpe.setText("0");
  39.                   break;
  40.               }  
  41.           }
  42.         case ("THROTTLE"):
  43.       {
  44.             if(auto.getMotore().equals("ON"))
  45.             {
  46.               if(auto.getVel()<250)  
  47.               {
  48.                  auto.accelera();
  49.                  txSpe.setText(String.valueOf(auto.getVel()));
  50.                  break;
  51.               }
  52.           }
  53.         }
  54.         case ("BRAKE"):
  55.       {
  56.              if(auto.getMotore().equals("ON"))
  57.              {
  58.                 auto.decelera();
  59.                 txSpe.setText(String.valueOf(auto.getVel()));
  60.                 break;
  61.              }
  62.         }
  63.       }
  64.     }
  65.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement