Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.event.*;
- import java.awt.*;
- public class GestorePulsanti implements ActionListener
- {
- private Automobile auto;
- private TextField txEng;
- private TextField txSpe;
- private TextField txGear;
- public GestorePulsanti(Automobile a,TextField te,TextField ts,TextField tg)
- {
- auto=a;
- txEng=te;
- txSpe=ts;
- txGear=tg;
- }
- public void actionPerformed(ActionEvent e)
- {
- String bottone=e.getActionCommand();
- switch(bottone)
- {
- case ("Start"):
- {
- if(txEng.getText().equals("OFF"))
- {
- auto.accendi();
- txEng.setText(null);
- txEng.setText(auto.getMotore());
- }
- break;
- }
- case ("Stop"):
- {
- if(txEng.getText().equals("ON"))
- {
- auto.spegni();
- txEng.setText(null);
- txEng.setText(auto.getMotore());
- txSpe.setText("0");
- break;
- }
- }
- case ("THROTTLE"):
- {
- if(auto.getMotore().equals("ON"))
- {
- if(auto.getVel()<250)
- {
- auto.accelera();
- txSpe.setText(String.valueOf(auto.getVel()));
- break;
- }
- }
- }
- case ("BRAKE"):
- {
- if(auto.getMotore().equals("ON"))
- {
- auto.decelera();
- txSpe.setText(String.valueOf(auto.getVel()));
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement