View Single Post
  #6   Spotlight this post!  
Unread 07-02-2016, 12:10 AM
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 298
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Is my code good?

Quote:
Originally Posted by olidem123 View Post
I use 2 commands because I found it easier to set up 2 buttons to one command each.
Well you'd have a constructor parameter that specifies which direction to roll the ball.
Code:
public enum Direction {
    IN,
    OUT
}
// ...
public class BallCommand extends Command {
    Direction whichDirection;
    public MyCommand(Direction whichDirection){
        this.whichDirection = whichDirection;
    }
    // ...
}
// ...
// then in OI
Button buttonA = new JoystickButton(stick, 1),
       buttonY = new JoystickButton(stick, 4);
buttonA.whenPressed(new BallCommand(Direction.IN));
buttonY.whenPressed(new BallCommand(Direction.OUT));
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote