Created
November 8, 2017 22:39
-
-
Save tervay/38b103e2ea758958ab8751eafe4a431f to your computer and use it in GitHub Desktop.
Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DriveTrain { | |
public void processAction(Action action) { | |
if (action.spec.equals("forwards")) { | |
driveForwards(action.magnitude); | |
} | |
} | |
public void driveForwards(int magnitude) { | |
// ... | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Intake { | |
public void processAction(Action action) { | |
if (action.spec.equals("extend")) { | |
extend(); | |
} | |
} | |
public void extend() { | |
// ... | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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