Skip to content

Instantly share code, notes, and snippets.

@tervay
Created November 8, 2017 22:39
Show Gist options
  • Save tervay/38b103e2ea758958ab8751eafe4a431f to your computer and use it in GitHub Desktop.
Save tervay/38b103e2ea758958ab8751eafe4a431f to your computer and use it in GitHub Desktop.
Sample
public class DriveTrain {
public void processAction(Action action) {
if (action.spec.equals("forwards")) {
driveForwards(action.magnitude);
}
}
public void driveForwards(int magnitude) {
// ...
}
}
public class Intake {
public void processAction(Action action) {
if (action.spec.equals("extend")) {
extend();
}
}
public void extend() {
// ...
}
}
public class Robot {
DriveTrain driveTrain;
Intake intake;
public void initMethod() {
driveTrain = new DriveTrain();
intake = new Intake();
// This is where the magic happens, it's as easy as this:
AutoConfig ac = new AutoConfig("auto.json"); // pass it your json file
ac.registerAction("drive", driveTrain);
ac.registerAction("intake", intake);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment