It is advised to statically import this class (or one of its inner classes) wherever the
13 | * constants are needed, to reduce verbosity.
14 | */
15 | public final class Constants {}
16 |
--------------------------------------------------------------------------------
/2021/05_inheritance/pak_lau/Berserker.java:
--------------------------------------------------------------------------------
1 | public class Berserker extends Hero {
2 |
3 | public Berserker(int attack, int maxHealth, String name) {
4 | super(attack, maxHealth, 50, "rage", name);
5 | }
6 |
7 | @Override
8 | public int getAttack() {
9 | if(getResource() >= 30)
10 | return 2 * super.getAttack();
11 | else {
12 | setResource(getResource() + 10);
13 | return super.getAttack();
14 | }
15 | }
16 |
17 | public int burst() {
18 | int n = getResource();
19 | setResource(0);
20 | return useAbility("burst", n);
21 | }
22 |
23 | public void heal() {
24 | int n = getResource();
25 | setResource(0);
26 | setHealth(getHealth() + n);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/2021/05_inheritance/dylan_hai/Berserker.java:
--------------------------------------------------------------------------------
1 | public class Berserker extends Hero {
2 | public Berserker(String name, int maxHealth, int attack, String resourceType, int maxResource){
3 | super(name, maxHealth, attack, resourceType, maxResource);
4 | this.setmaxResource(50);
5 | this.setResourceType("Rage");
6 | }
7 |
8 | @Override
9 | public int getAttack(){
10 | if (this.getMaxResource()>=30){
11 | return 2*this.getAttack();
12 | }
13 | else {
14 | this.setCurrResource(this.getCurrResource()+10);
15 | return this.getAttack();
16 | }
17 | }
18 | public void burst() {
19 | useAbility("burst",0);
20 | }
21 | public void heal() {
22 | this.setCurrResource(this.getMaxResource());
23 | }
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/2023/09_OOP4/robot/Shooter.java:
--------------------------------------------------------------------------------
1 | package robot;
2 | public class Shooter extends AbstractRobot {
3 | private double shooterSpeed;
4 | private double hoodAngle;
5 |
6 | // Constructor for Shooter class
7 | public Shooter(String teamName, int teamNumber, double shooterSpeed, double hoodAngle) {
8 | super(teamName, teamNumber);
9 | this.shooterSpeed = shooterSpeed;
10 | this.hoodAngle = hoodAngle;
11 | }
12 |
13 | public double getShooterSpeed() {
14 | return shooterSpeed;
15 | }
16 | public void setShooterSpeed(double shooterSpeed) {
17 | this.shooterSpeed = shooterSpeed;
18 | }
19 | public double getHoodAngle() {
20 | return hoodAngle;
21 | }
22 | public void setHoodAngle(double hoodAngle) {
23 | this.hoodAngle = hoodAngle;
24 | }
25 | }
--------------------------------------------------------------------------------
/2021/05_inheritance/Eric_Lin/Beserker.java:
--------------------------------------------------------------------------------
1 | public class Beserker extends Hero{
2 | public Berserker(String name, int atk, int maxHP){
3 | super(name, currentHP, maxHP, atk, "rage", currentResource, 50);
4 | }
5 | @override
6 | public int getAtk(){
7 | if(getCurrentResource >= 30)
8 | return 2 * super.getAtk();
9 | else
10 | setCurrentResource(10 + getCurrentResource());
11 | return super.getAtk();
12 | }
13 | public burst(int n){
14 | setCurrentResource(0);
15 | int n = getCurrentResource();
16 | return useAbility("burst", 0);
17 | }
18 | public heal(){
19 | setCurrentHP(getCurrentResource() + getCurrentHP());
20 | setCurrentResource(0);
21 | return useAbility("heal", 0);
22 | }
23 |
24 |
25 |
26 | }
--------------------------------------------------------------------------------
/2021/06_git2/group1/YasuoBug.java:
--------------------------------------------------------------------------------
1 | package group1;
2 |
3 | import info.gridworld.actor.Bug;
4 |
5 | public class YasuoBug extends Bug {
6 | int steps;
7 | int length;
8 |
9 | public YasuoBug(int length) {
10 | this.steps = 0;
11 | this.length = length;
12 | }
13 |
14 | public YasuoBug() {
15 | this.steps = 0;
16 | this.length = 4;
17 | }
18 |
19 | private void halfTurn() {
20 | for(int i = 0; i < 4; i++) {
21 | turn();
22 | }
23 | }
24 |
25 |
26 | @Override
27 | public void act() {
28 | if(steps < length && canMove()) {
29 |
30 | move();
31 | steps++;
32 | }
33 | else {
34 |
35 | halfTurn();
36 | steps = 0;
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/2021/06_git2/mahir_riki/BoxBug.java:
--------------------------------------------------------------------------------
1 | package mahir_riki;
2 |
3 | import javax.swing.Box;
4 |
5 | import info.gridworld.actor.Bug;
6 |
7 | public class BoxBug extends Bug {
8 | int steps;
9 | int length;
10 |
11 | public BoxBug(int length) {
12 | this.steps = 0;
13 | this.length = length;
14 | }
15 |
16 | public BoxBug() {
17 | this.steps = 0;
18 | this.length = 4;
19 | }
20 |
21 | public void quarterTurn() {
22 | for(int i = 0; i < 2; i++) {
23 | turn();
24 | }
25 | }
26 |
27 | @Override
28 | public void act() {
29 | if(steps < length && canMove()) {
30 | move();
31 | steps++;
32 | }
33 | else {
34 | quarterTurn();
35 | steps = 0;
36 | }
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/2022/RichieBot/src/main/java/frc/robot/commands/TankDriveCommand.java:
--------------------------------------------------------------------------------
1 | package frc.robot.commands;
2 |
3 | import com.stuypulse.stuylib.input.Gamepad;
4 |
5 | import edu.wpi.first.wpilibj2.command.CommandBase;
6 | import frc.robot.subsystems.RomiDrivetrain;
7 |
8 | public class TankDriveCommand extends CommandBase {
9 | private RomiDrivetrain andrew;
10 | private Gamepad driver;
11 |
12 | public TankDriveCommand(RomiDrivetrain driveTrain, Gamepad gamepad)
13 | {
14 | andrew = driveTrain;
15 | driver = gamepad;
16 |
17 | addRequirements(andrew);
18 | }
19 |
20 | public void execute() {
21 | andrew.tankDrive(
22 | driver.getLeftY(),
23 | driver.getRightY()
24 | );
25 | }
26 |
27 | public boolean isFinished() {
28 | return false;
29 | }
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/2021/08_newbierobot/.project:
--------------------------------------------------------------------------------
1 |
2 |
If you change your main robot class, change the parameter type. 21 | */ 22 | public static void main(String... args) { 23 | RobotBase.startRobot(Robot::new); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /2020/Lesson #1/Lesson Plan.txt: -------------------------------------------------------------------------------- 1 | The plan of the fist lesson is to cover the topics in this slide. 2 | https://docs.google.com/presentation/d/1z1E3HLfAEsyye_5G5BnJzk1hj3ShV2cvw7eL7QBW2Co 3 | 4 | Instead of doing the slide, I am considering doing live coding to explain subjects 5 | as it allows me to explain things using code instead of pointing to examples in the 6 | slide. 7 | 8 | I think it might be more adaptable. The Lesson.java file in this folder is the 9 | plan that I would plan to take the live code in. It comes with explainations 10 | and code that should be used in the lesson. 11 | 12 | My plan is to cover: 13 | - Comments 14 | - Variables 15 | - Print Statements 16 | - Conditionals / If Statements 17 | - While Loops 18 | - For Loops? 19 | - Imports? 20 | - Objects 21 | - Opening a file? 22 | - Functions? 23 | - Calling them 24 | - Inputs 25 | - Outputs -------------------------------------------------------------------------------- /2021/03_java/april_jang_two_practice/Secret.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Secret { 4 | public static void main(String [] args) { 5 | Scanner usersInput = new Scanner(System.in); 6 | String secretWord = "April"; 7 | String guess = ""; 8 | System.out.println("I'm thinking of a word!"); 9 | int guessTrys = 0; 10 | int guessStop = 3; 11 | boolean tooMuch = false; 12 | 13 | while (!guess.equals(secretWord) && !tooMuch) { 14 | 15 | if (guessTrys < guessStop) { 16 | 17 | System.out.print("Enter a guess: "); 18 | guess = usersInput.nextLine(); 19 | guessTrys++; 20 | 21 | } else { 22 | tooMuch = true; 23 | } 24 | } 25 | } 26 | if (tooMuch) { 27 | 28 | System.out.println("You lose, you couldn't guess the word in enough tries!"); 29 | 30 | } else { 31 | System.out.println("You guess the word correctly!"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /2023/08_OOP3/Main.java: -------------------------------------------------------------------------------- 1 | public class Main { 2 | public static void main(String[] args) { 3 | Circle c1 = new Circle(); 4 | // Invoke public methods on instance c1, via dot operator. 5 | System.out.println("The circle has radius of " 6 | + c1.getRadius() + " and area of " + c1.getArea()); 7 | //The circle has radius of 1.0 and area of 3.141592653589793 8 | 9 | // Declare an instance of class circle called c2. 10 | // Construct the instance c2 by invoking the second constructor 11 | // with the given radius and default color. 12 | Circle c2 = new Circle(2.0); 13 | // Invoke public methods on instance c2, via dot operator. 14 | System.out.println("The circle has radius of " 15 | + c2.getRadius() + " and circumference of " + c2.getCircumference()); 16 | //The circle has radius of 2.0 and circumference of 12.566370614359172 17 | 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "type": "java", 5 | "name": "Main", 6 | "request": "launch", 7 | "mainClass": "Main", 8 | "projectName": "newbie-ed_7dbd7922" 9 | }, 10 | { 11 | "type": "java", 12 | "name": "Lesson7", 13 | "request": "launch", 14 | "mainClass": "Lesson7", 15 | "projectName": "newbie-ed_7dbd7922" 16 | }, 17 | { 18 | "type": "java", 19 | "name": "CodeLens (Launch) - Main", 20 | "request": "launch", 21 | "mainClass": "Main", 22 | "projectName": "newbie-ed_4a15b88d" 23 | }, 24 | { 25 | "type": "java", 26 | "name": "Debug (Launch) - Current File", 27 | "request": "launch", 28 | "mainClass": "${file}" 29 | } 30 | ] 31 | } -------------------------------------------------------------------------------- /2021/08_newbierobot/src/main/java/frc/robot/Main.java: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------*/ 2 | /* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ 5 | /* the project. */ 6 | /*----------------------------------------------------------------------------*/ 7 | 8 | package frc.robot; 9 | 10 | import edu.wpi.first.wpilibj.RobotBase; 11 | 12 | /** 13 | * This class is JUST to initialize the robot. 14 | * There is nothing to look at here 15 | */ 16 | public final class Main { 17 | private Main() { 18 | } 19 | 20 | public static void main(String... args) { 21 | RobotBase.startRobot(Robot::new); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /2022/RichieBot/src/main/java/frc/robot/subsystems/Bread.java: -------------------------------------------------------------------------------- 1 | package frc.robot.subsystems; 2 | 3 | import edu.wpi.first.wpilibj.Spark; 4 | import edu.wpi.first.wpilibj2.command.SubsystemBase; 5 | 6 | public class Bread extends SubsystemBase { 7 | private Spark wheat; // = new Spark(-1); 8 | private Spark flour; 9 | 10 | public Bread(){ 11 | wheat = new Spark(0); 12 | flour = new Spark(1); 13 | 14 | flour.setInverted(true); 15 | } 16 | 17 | @Override 18 | public void periodic() { 19 | } 20 | 21 | public void bake(double wheatSpeed, double flourSpeed) { 22 | wheat.set(wheatSpeed); 23 | flour.set(flourSpeed); 24 | } 25 | 26 | public void fry(double wheatness, double flourness){ 27 | bake( 28 | wheatness+flourness, 29 | wheatness-flourness 30 | ); 31 | } 32 | 33 | public void freeze() { 34 | wheat.set(0.0); 35 | flour.set(0.0); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /2021/04_oop/jonathan_deng/Car.java: -------------------------------------------------------------------------------- 1 | public class Car { 2 | private String model; 3 | private String color; 4 | private int mileage = 0; 5 | private static final int MAX_MILEAGE = 20; 6 | public Car(String model, String color) { 7 | this.model = model; 8 | this.color = color; 9 | } 10 | public Car(String model) { 11 | this.model = model; 12 | color="colourless"; 13 | } 14 | 15 | 16 | public void explode() { 17 | for (int i=5;i > 0;i--){ 18 | System.out.println(i); 19 | } 20 | System.out.println("haha car go boom"); 21 | } 22 | public boolean willExplode(){ 23 | return(mileage>=MAX_MILEAGE); 24 | } 25 | public void repair() { 26 | System.out.println("Repaired!"); 27 | } 28 | public String toString() { 29 | return "This car is a " + color + " " + model; 30 | } 31 | public void drive(){ 32 | if(willExplode()) 33 | explode(); 34 | else{ 35 | System.out.println("vroom"); 36 | mileage++; 37 | 38 | } 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /2022/RichieBot/settings.gradle: -------------------------------------------------------------------------------- 1 | import org.gradle.internal.os.OperatingSystem 2 | 3 | pluginManagement { 4 | repositories { 5 | mavenLocal() 6 | gradlePluginPortal() 7 | String frcYear = '2021' 8 | File frcHome 9 | if (OperatingSystem.current().isWindows()) { 10 | String publicFolder = System.getenv('PUBLIC') 11 | if (publicFolder == null) { 12 | publicFolder = "C:\\Users\\Public" 13 | } 14 | def homeRoot = new File(publicFolder, "wpilib") 15 | frcHome = new File(homeRoot, frcYear) 16 | } else { 17 | def userFolder = System.getProperty("user.home") 18 | def homeRoot = new File(userFolder, "wpilib") 19 | frcHome = new File(homeRoot, frcYear) 20 | } 21 | def frcHomeMaven = new File(frcHome, 'maven') 22 | maven { 23 | name 'frcHome' 24 | url frcHomeMaven 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /2020/Lesson #3/src/main/java/frc/robot/commands/FloopOpenCommand.java: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------*/ 2 | /* Copyright (c) 2018 FIRST. All Rights Reserved. */ 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ 5 | /* the project. */ 6 | /*----------------------------------------------------------------------------*/ 7 | 8 | package frc.robot.commands; 9 | 10 | import edu.wpi.first.wpilibj.command.Command; 11 | import frc.robot.Robot; 12 | 13 | public class FloopOpenCommand extends Command { 14 | public FloopOpenCommand() { 15 | requires(Robot.floop); 16 | } 17 | 18 | @Override 19 | protected void initialize() { 20 | Robot.floop.open(); 21 | } 22 | 23 | @Override 24 | protected boolean isFinished() { 25 | return true; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /2020/Lesson #3/src/main/java/frc/robot/commands/FloopPullCommand.java: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------*/ 2 | /* Copyright (c) 2018 FIRST. All Rights Reserved. */ 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ 5 | /* the project. */ 6 | /*----------------------------------------------------------------------------*/ 7 | 8 | package frc.robot.commands; 9 | 10 | import edu.wpi.first.wpilibj.command.Command; 11 | import frc.robot.Robot; 12 | 13 | public class FloopPullCommand extends Command { 14 | public FloopPullCommand() { 15 | requires(Robot.floop); 16 | } 17 | 18 | @Override 19 | protected void initialize() { 20 | Robot.floop.pull(); 21 | } 22 | 23 | @Override 24 | protected boolean isFinished() { 25 | return true; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /2020/Lesson #3/src/main/java/frc/robot/commands/FloopPushCommand.java: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------*/ 2 | /* Copyright (c) 2018 FIRST. All Rights Reserved. */ 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ 5 | /* the project. */ 6 | /*----------------------------------------------------------------------------*/ 7 | 8 | package frc.robot.commands; 9 | 10 | import edu.wpi.first.wpilibj.command.Command; 11 | import frc.robot.Robot; 12 | 13 | public class FloopPushCommand extends Command { 14 | public FloopPushCommand() { 15 | requires(Robot.floop); 16 | } 17 | 18 | @Override 19 | protected void initialize() { 20 | Robot.floop.push(); 21 | } 22 | 23 | @Override 24 | protected boolean isFinished() { 25 | return true; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /2021/08_newbierobot/settings.gradle: -------------------------------------------------------------------------------- 1 | import org.gradle.internal.os.OperatingSystem 2 | 3 | pluginManagement { 4 | repositories { 5 | mavenLocal() 6 | gradlePluginPortal() 7 | String frcYear = '2020' 8 | File frcHome 9 | if (OperatingSystem.current().isWindows()) { 10 | String publicFolder = System.getenv('PUBLIC') 11 | if (publicFolder == null) { 12 | publicFolder = "C:\\Users\\Public" 13 | } 14 | def homeRoot = new File(publicFolder, "wpilib") 15 | frcHome = new File(homeRoot, frcYear) 16 | } else { 17 | def userFolder = System.getProperty("user.home") 18 | def homeRoot = new File(userFolder, "wpilib") 19 | frcHome = new File(homeRoot, frcYear) 20 | } 21 | def frcHomeMaven = new File(frcHome, 'maven') 22 | maven { 23 | name 'frcHome' 24 | url frcHomeMaven 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /2020/Lesson #3/src/main/java/frc/robot/commands/FloopCloseCommand.java: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------*/ 2 | /* Copyright (c) 2018 FIRST. All Rights Reserved. */ 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ 5 | /* the project. */ 6 | /*----------------------------------------------------------------------------*/ 7 | 8 | package frc.robot.commands; 9 | 10 | import edu.wpi.first.wpilibj.command.Command; 11 | import frc.robot.Robot; 12 | 13 | public class FloopCloseCommand extends Command { 14 | public FloopCloseCommand() { 15 | requires(Robot.floop); 16 | } 17 | 18 | @Override 19 | protected void initialize() { 20 | Robot.floop.close(); 21 | } 22 | 23 | @Override 24 | protected boolean isFinished() { 25 | return true; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /2023/08_OOP3/Circle.java: -------------------------------------------------------------------------------- 1 | public class Circle { 2 | private double radius; 3 | private String color; 4 | public Circle(double radius,String color){ 5 | this.radius = radius; 6 | this.color = color; 7 | 8 | } 9 | public Circle(double radius){ 10 | this.radius = radius; 11 | this.color = "Red"; 12 | 13 | } 14 | public Circle() { 15 | this.radius = 1; 16 | this.color = "Red"; 17 | } 18 | public double getRadius(){ 19 | return this.radius; 20 | } 21 | public String getColor(){ 22 | return this.color; 23 | } 24 | public void setRadius(double radius){ 25 | this.radius = radius; 26 | } 27 | public void setColor(String color){ 28 | this.color = color; 29 | } 30 | 31 | public double getArea() { 32 | return Math.PI * Math.pow(this.radius,2); 33 | } 34 | 35 | public double getCircumference() { 36 | return Math.PI * 2 * this.radius; 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /2020/Lesson #3/src/main/java/frc/robot/commands/FloopStopScoreCommand.java: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------*/ 2 | /* Copyright (c) 2018 FIRST. All Rights Reserved. */ 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ 5 | /* the project. */ 6 | /*----------------------------------------------------------------------------*/ 7 | 8 | package frc.robot.commands; 9 | 10 | import edu.wpi.first.wpilibj.command.CommandGroup; 11 | import edu.wpi.first.wpilibj.command.WaitCommand; 12 | 13 | public class FloopStopScoreCommand extends CommandGroup { 14 | 15 | public FloopStopScoreCommand() { 16 | addSequential(new FloopPullCommand()); 17 | addSequential(new WaitCommand(0.25)); //adds a pause between these two commands 18 | addSequential(new FloopOpenCommand()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /2021/04_oop/pak_lau/Car.java: -------------------------------------------------------------------------------- 1 | public class Car { 2 | private String model; 3 | private String color; 4 | private int mileage = 0; 5 | private static final int MAX_MILEAGE = 20; 6 | 7 | public Car(String model, String color) { 8 | this.model = model; 9 | this.color = color; 10 | } 11 | 12 | public Car(String model) { 13 | this.model = model; 14 | color = "colorless"; 15 | } 16 | 17 | public boolean willExplode() { 18 | return mileage >= MAX_MILEAGE; 19 | } 20 | 21 | public void explode() { 22 | for(int i = 5; i > 0; i--) { 23 | System.out.println(i); 24 | } 25 | System.out.println("haha car go boom"); 26 | } 27 | 28 | public void drive() { 29 | if(willExplode()) { 30 | explode(); 31 | }else { 32 | System.out.println("vroom"); 33 | mileage++; 34 | } 35 | } 36 | 37 | public void repair() { 38 | mileage = 0; 39 | System.out.println("Repaired!"); 40 | } 41 | 42 | public String toString() { 43 | return "This car is a " + color + " " + model; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /2021/04_oop/yaqi_chew/Car.java: -------------------------------------------------------------------------------- 1 | public class Car { 2 | private String model; 3 | private String color; 4 | private int mileage = 0; 5 | private static final int MAX_MILEAGE = 20; 6 | 7 | public Car(String model, String color) { 8 | this.model = model; 9 | this.color = color; 10 | } 11 | 12 | public Car(String model) { 13 | this. model = model; 14 | this. color = "colorless"; 15 | } 16 | 17 | public void repair() { 18 | mileage = 0; 19 | System.out.println("Repaired!"); 20 | } 21 | 22 | public boolean willExplode() { 23 | return mileage >= MAX_MILEAGE; 24 | } 25 | 26 | public String toString() { 27 | return "This car is a " + color + " " + model; 28 | } 29 | private void explode() { 30 | for(int i=5; i > 0; i--){ 31 | System.out.println(i); 32 | } 33 | System.out.println("haha car go boom"); 34 | } 35 | public void drive(){ 36 | if(willExplode()) 37 | explode(); 38 | else{ 39 | System.out.println("vroom"); 40 | mileage++; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /2021/05_inheritance/dylan_hai/Knight.java: -------------------------------------------------------------------------------- 1 | public class Knight extends Hero { 2 | public Knight(String name, int maxHealth, int attack, String resourceType, int maxResource){ 3 | super(name, maxHealth, attack, resourceType, maxResource); 4 | this.setResourceType("Armor"); 5 | this.setmaxResource(15); 6 | this.setCurrResource(15); 7 | } 8 | 9 | @Override 10 | public void takeDamage(int n){ 11 | if (n>this.getMaxResource()){ 12 | this.takeDamage(n-this.getMaxResource()); 13 | } 14 | } 15 | @Override 16 | public int getAttack(){ 17 | if (this.getCurrResource()+5>this.getMaxResource()){ 18 | this.setCurrResource(this.getMaxResource()); 19 | } 20 | else { 21 | this.setCurrResource(this.getCurrResource()+5); 22 | 23 | } 24 | return this.getAttack(); 25 | } 26 | public void charge(){ 27 | useAbility("charge",3*getCurrResource()); 28 | this.setCurrResource(0); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /2021/04_oop/lin_eric/Car.java: -------------------------------------------------------------------------------- 1 | public class Car { 2 | private String model; 3 | private String color; 4 | private int milage; 5 | private static final int MAX_MILAGE = 20; 6 | 7 | public Car(String model, String color) { 8 | this.model = model; 9 | this.color = color; 10 | } 11 | public Car(String model){ 12 | this.model = model; 13 | color = "colorless"; 14 | } 15 | 16 | public void repair() { 17 | milage = 0; 18 | System.out.println("Repaired!"); 19 | } 20 | public boolean willExplode() { 21 | if(milage >= MAX_MILAGE){ 22 | return true;} 23 | return false; 24 | } 25 | public void explode() { 26 | for(int explodeOrNot = 5; explodeOrNot >=0; explodeOrNot --){System.out.println(explodeOrNot); 27 | if(explodeOrNot == 0){ 28 | System.out.println("haha car go boom"); 29 | }}} 30 | public String toString() { 31 | return "This car is a " + color + " " + model; 32 | } 33 | public void drive(){ 34 | if( willExplode() == true) 35 | {explode();} 36 | else{ 37 | System.out.println("vroom"); 38 | milage++; 39 | }}} 40 | -------------------------------------------------------------------------------- /2021/08_newbierobot/src/main/java/frc/robot/subsystems/Shooter.java: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------*/ 2 | /* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ 5 | /* the project. */ 6 | /*----------------------------------------------------------------------------*/ 7 | 8 | package frc.robot.subsystems; 9 | 10 | import edu.wpi.first.wpilibj2.command.SubsystemBase; 11 | 12 | import com.ctre.phoenix.motorcontrol.can.WPI_VictorSPX; 13 | 14 | import frc.robot.Constants.Ports; 15 | 16 | public class Shooter extends SubsystemBase { 17 | WPI_TalonSPX motor; 18 | 19 | public Shooter() { 20 | motor = new WPI_VictorSPX(Ports.SHOOTER); 21 | } 22 | 23 | public void set(double speed) { 24 | motor.set(speed); 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /2021/04_oop/kevin_li/Car.java: -------------------------------------------------------------------------------- 1 | public class Car { 2 | private String model; 3 | private String color; 4 | private int mileage = 0; 5 | private static final int MAX_MILEAGE = 20; 6 | private int x = 5; 7 | public Car(String model, String color) { 8 | this.model = model; 9 | this.color = color; 10 | this.mileage = 0; 11 | } 12 | public Car(String model) { 13 | this.color = model; 14 | color = "colorless"; 15 | } 16 | public boolean willExplode() { 17 | if (mileage >= MAX_MILEAGE) 18 | return true; 19 | return false; 20 | } 21 | public void repair() { 22 | mileage = 0; 23 | System.out.println("Repaired!"); 24 | } 25 | private void explode() { 26 | while (x > 0) { 27 | System.out.println(x--); 28 | } 29 | if (x == 0) 30 | System.out.println("haha car go boom"); 31 | } 32 | public void drive() { 33 | if (willExplode()) 34 | explode(); 35 | else System.out.println("vroom"); 36 | mileage++; 37 | } 38 | public String toString() { 39 | return "This car is a " + color + " " + model; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /2021/04_oop/elaine_ye/Car.java: -------------------------------------------------------------------------------- 1 | public class Car { 2 | private String model; 3 | private String color; 4 | private int mileage = 0; 5 | private static final int MAX_MILEAGE = 20; 6 | 7 | public Car(String model, String color) { 8 | this.model = model; 9 | this.color = color; 10 | } 11 | 12 | public Car(String model) { 13 | this.model = model; 14 | color = "colorless"; 15 | } 16 | 17 | public boolean willExplode() { 18 | return mileage >= MAX_MILEAGE; 19 | } 20 | 21 | public void repair() { 22 | mileage = 0; 23 | System.out.println("Repaired!"); 24 | } 25 | 26 | private void explode() { 27 | for (int countdown = 5; countdown >= 0; countdown--) { 28 | System.out.println(countdown); 29 | } 30 | System.out.println("haha car go boom boom"); 31 | } 32 | public void drive() { 33 | if (willExplode()) { 34 | explode(); 35 | } else { 36 | System.out.println("vroom"); 37 | mileage++; 38 | } 39 | } 40 | 41 | public String toString() { 42 | return "This car is a " + color + " " + model; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /2021/04_oop/Kirill_Vesialou/Car.java: -------------------------------------------------------------------------------- 1 | public class Car { 2 | private String model; 3 | private String color; 4 | private int mileage = 0 5 | private static final int MAX_MILEAGE = 20; 6 | 7 | public Car(String model, String color) { 8 | this.model = model; 9 | this.color = "colorless"; 10 | } 11 | 12 | public void repair() { 13 | int mileage = 0 14 | System.out.println("Repaired!"); 15 | } 16 | 17 | public String toString() { 18 | return "This car is a " + color + " " + model; 19 | } 20 | 21 | 22 | public boolean willExplode() { 23 | if (mileage>=MAX_MILEAGE) { 24 | return true; 25 | } 26 | else { 27 | return false; 28 | } 29 | } 30 | 31 | public void explode() { 32 | for(i = 5, i > 0, i--); { 33 | System.out.println(i); 34 | } 35 | if (i=0) { 36 | System.out.println("haha car go boom"); 37 | } 38 | } 39 | 40 | public void drive () { 41 | if (willExplode()) 42 | explode(); 43 | } 44 | else { 45 | System.out.println("vroom"); 46 | mileage++; 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /2021/04_oop/april_jang/Car.java: -------------------------------------------------------------------------------- 1 | public class Car { 2 | private String model; 3 | private String color; 4 | private int mileage = 0; 5 | private static final int MAX_MILEAGE = 20; 6 | 7 | 8 | public Car(String model, String color) { 9 | this.model = model; 10 | this.color = color; 11 | } 12 | 13 | public Car(String model) { 14 | this.model = model; 15 | this.color = "Colorless"; 16 | } 17 | 18 | public void repair() { 19 | mileage = 0; 20 | System.out.println("Repaired!"); 21 | } 22 | 23 | public boolean willExplode () { 24 | return mileage >= MAX_MILEAGE; 25 | } 26 | 27 | private void explode() { 28 | for (int i = 5; i > 0; i--) { 29 | System.out.println(i); 30 | } 31 | 32 | System.out.println("haha car go boom"); 33 | } 34 | 35 | public void drive() { 36 | if (willExplode()) { 37 | explode(); 38 | } 39 | 40 | else { 41 | System.out.println("Vroom Vroom"); 42 | mileage++; 43 | } 44 | } 45 | 46 | public String toString() { 47 | return "This car is a " + color + " " + model; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /2020/Lesson #3/src/main/java/frc/robot/commands/FloopStartScoreCommand.java: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------*/ 2 | /* Copyright (c) 2018 FIRST. All Rights Reserved. */ 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ 5 | /* the project. */ 6 | /*----------------------------------------------------------------------------*/ 7 | 8 | package frc.robot.commands; 9 | 10 | import edu.wpi.first.wpilibj.command.CommandGroup; 11 | 12 | public class FloopStartScoreCommand extends CommandGroup { 13 | 14 | //command groups are a sequence of groups that are run in order 15 | //used for autons, for example 16 | //addSequential adds commands that will run one after the other 17 | //addParallel adds commands that will run together 18 | public FloopStartScoreCommand() { 19 | addSequential(new FloopCloseCommand()); 20 | addSequential(new FloopPushCommand()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /2021/08_newbierobot/src/main/java/frc/robot/commands/DrivetrainSpinCommand.java: -------------------------------------------------------------------------------- 1 | package frc.robot.commands; 2 | 3 | import frc.robot.subsystems.Drivetrain; 4 | 5 | import edu.wpi.first.wpilibj2.command.CommandBase; 6 | import com.stuypulse.stuylib.input.Gamepad; 7 | 8 | public class DrivetrainDriveCommand extends CommandBase { 9 | 10 | // TODO: Make Drivetrain Drive Command 11 | private Drivetrain drivetrain; 12 | 13 | public DrivetrainDriveCommand(Drivetrain drivetrain) { 14 | // TODO: Add requirements 15 | this.drivetrain = drivetrain; 16 | 17 | addRequirements(drivetrain); 18 | } 19 | 20 | public void initialize() { 21 | 22 | } 23 | 24 | public void execute() { 25 | drivetrain.tankDrive(-1, 1); 26 | } 27 | 28 | public boolean isFinished() { 29 | if ((1 > 0) == true) { 30 | return false; 31 | } 32 | else { 33 | // this is how people die 34 | // if 0 > 1 then we should die 35 | // what if a 36 | drivetrain.tankDrive(1, 1); 37 | } 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /2021/04_oop/raihan_nadeem/Car.java: -------------------------------------------------------------------------------- 1 | public class Car { 2 | private String model; 3 | private String color; 4 | private int mileage = 0; 5 | private static final int MAX_MILEAGE = 20; 6 | public Car(String model, String color) { 7 | this.model = model; 8 | this.color = color; 9 | } 10 | public Car(String model) { 11 | this.model = model; 12 | this.color = "colorless"; 13 | } 14 | public boolean willExplode() { 15 | return mileage >= MAX_MILEAGE; 16 | } 17 | public void repair() { 18 | mileage = 0; 19 | System.out.println("Repaired!"); 20 | } 21 | private void explode() { 22 | System.out.println("5"); 23 | System.out.println("4"); 24 | System.out.println("3"); 25 | System.out.println("2"); 26 | System.out.println("1"); 27 | System.out.println("0"); 28 | System.out.println("haha car go boom"); 29 | } 30 | public void drive() { 31 | if (willExplode()) { 32 | explode(); 33 | } else { 34 | System.out.println("vroom"); 35 | mileage++; 36 | } 37 | } 38 | 39 | public String toString() { 40 | return "This car is a " + color + " " + model; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /2021/06_git2/group3/BoxBugKevin.java: -------------------------------------------------------------------------------- 1 | package group3; 2 | 3 | import info.gridworld.actor.Bug; 4 | 5 | public class BoxBugKevin extends Bug { 6 | int steps; // a counter for how many steps we have taken 7 | int length; // how far the bug will move 8 | 9 | public BoxBugKevin(int length) { 10 | this.steps = 0; 11 | this.length = length; 12 | } 13 | 14 | public BoxBugKevin() { 15 | this.steps = 0; 16 | this.length = 4; // 4 is the default 17 | } 18 | 19 | // this is a helper funtion 20 | // it was not in the original Bug class 21 | private void quarterTurn() { 22 | for(int i = 0; i < 2; i++) { 23 | turn(); 24 | } 25 | } 26 | 27 | // this method will run once every loop 28 | @Override 29 | public void act() { 30 | if(steps < length && canMove()) { 31 | // move and increment steps 32 | move(); 33 | steps++; 34 | } 35 | else { 36 | // turn around and set counter to 0 37 | quarterTurn(); 38 | steps = 0; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 StuyPulse 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /2021/06_git2/example/LineBug.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import info.gridworld.actor.Bug; 4 | 5 | public class LineBug extends Bug { 6 | int steps; // a counter for how many steps we have taken 7 | int length; // how far the bug will move 8 | 9 | public LineBug(int length) { 10 | this.steps = 0; 11 | this.length = length; 12 | } 13 | 14 | public LineBug() { 15 | this.steps = 0; 16 | this.length = 4; // 4 is the default 17 | } 18 | 19 | // this is a helper funtion 20 | // it was not in the original Bug class 21 | private void halfTurn() { 22 | for(int i = 0; i < 4; i++) { 23 | turn(); 24 | } 25 | } 26 | 27 | // this method will run once every loop 28 | @Override 29 | public void act() { 30 | if(steps < length && canMove()) { 31 | // move and increment steps 32 | move(); 33 | steps++; 34 | } 35 | else { 36 | // turn around and set counter to 0 37 | halfTurn(); 38 | steps = 0; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /2021/08_newbierobot/vendordeps/navx_frc.json: -------------------------------------------------------------------------------- 1 | { 2 | "fileName": "navx_frc.json", 3 | "name": "KauaiLabs_navX_FRC", 4 | "version": "3.1.405", 5 | "uuid": "cb311d09-36e9-4143-a032-55bb2b94443b", 6 | "mavenUrls": [ 7 | "https://repo1.maven.org/maven2/" 8 | ], 9 | "jsonUrl": "https://www.kauailabs.com/dist/frc/2020/navx_frc.json", 10 | "javaDependencies": [ 11 | { 12 | "groupId": "com.kauailabs.navx.frc", 13 | "artifactId": "navx-java", 14 | "version": "3.1.405" 15 | } 16 | ], 17 | "jniDependencies": [], 18 | "cppDependencies": [ 19 | { 20 | "groupId": "com.kauailabs.navx.frc", 21 | "artifactId": "navx-cpp", 22 | "version": "3.1.405", 23 | "headerClassifier": "headers", 24 | "sourcesClassifier": "sources", 25 | "sharedLibrary": false, 26 | "libName": "navx_frc", 27 | "skipInvalidPlatforms": true, 28 | "binaryPlatforms": [ 29 | "linuxathena", 30 | "linuxraspbian", 31 | "windowsx86-x64" 32 | ] 33 | } 34 | ] 35 | } -------------------------------------------------------------------------------- /2022/RichieBot/src/main/java/frc/robot/commands/DriveDistanceCommand.java: -------------------------------------------------------------------------------- 1 | package frc.robot.commands; 2 | 3 | import edu.wpi.first.wpilibj2.command.CommandBase; 4 | import frc.robot.subsystems.RomiDrivetrain; 5 | 6 | public class DriveDistanceCommand extends CommandBase { 7 | private RomiDrivetrain richie; 8 | private double goalDistance; 9 | 10 | public DriveDistanceCommand(RomiDrivetrain richie, double goalDistance) { 11 | this.richie = richie; 12 | this.goalDistance = goalDistance; 13 | 14 | addRequirements(richie); 15 | } 16 | 17 | public void initialize() { 18 | richie.resetEncoders(); 19 | } 20 | 21 | public void execute() { 22 | richie.tankDrive(1,1); 23 | } 24 | 25 | public boolean isFinished() { 26 | if (richie.getLeftDistanceInch() < goalDistance) { 27 | return false; 28 | } else { 29 | return true; 30 | } 31 | // return richie.getLeftDistanceInch() > goalDistance; 32 | } 33 | 34 | public void end(boolean interrupted) { 35 | // richie.tankDrive(0, 0); 36 | richie.stop(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /2021/05_inheritance/kevin_li/hero.java: -------------------------------------------------------------------------------- 1 | public class Hero{ 2 | private String name; 3 | private String resourceType; 4 | private int attack; 5 | private int currentHealth; 6 | private int currentResource; 7 | private int maxHealth; 8 | private int maxResource; 9 | static int heroesMade = 0; 10 | 11 | public Hero(String name, int health, int attack, String resourceType,int resource) { 12 | this.name = name; 13 | this.resourceType = resourceType; 14 | maxHealth = currentHealth = health; 15 | maxResource = currentResource = resource; 16 | heroesMade++; 17 | } 18 | 19 | public int getMaxHealth(){ 20 | return maxHealth; 21 | } 22 | public int getCurrentHealth(){ 23 | return currentHealth; 24 | } 25 | public int attack(){ 26 | return attack; 27 | } 28 | public int getMaxResource(){ 29 | return maxResource; 30 | } 31 | public int getCurrentResource(){ 32 | return currentResource; 33 | } 34 | public String getName(){ 35 | return name; 36 | } 37 | public String getResourceType(){ 38 | return resourceType; 39 | } 40 | 41 | public void setMaxHealth(int arg){ 42 | maxHealth = arg; 43 | } 44 | public void setCurrentHealth(int arg){ 45 | currentHealth = arg; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /2023/11_Hardware/outtake/Outtake.java: -------------------------------------------------------------------------------- 1 | //copy pasted from our activities today, can be placed in Jim's subsystems folder to see work 2 | package com.stuypulse.robot.subsystems.outtake; 3 | import com.revrobotics.CANSparkMax; 4 | 5 | import edu.wpi.first.wpilibj.Encoder; 6 | import edu.wpi.first.wpilibj2.command.SubsystemBase; 7 | 8 | public class Outtake extends SubsystemBase { 9 | private CANSparkMax backMotor; 10 | 11 | private Encoder encoder; 12 | 13 | private double targetOuttakeSpeed; 14 | 15 | public Outtake() { 16 | backMotor = new CANSparkMax(1, CANSparkMax.MotorType.kBrushless); 17 | encoder = new Encoder(0, 1); 18 | targetOuttakeSpeed = 0.0; 19 | } 20 | 21 | public void setOutTakeSpeed(double outtakeSpeed) { 22 | backMotor.set(targetOuttakeSpeed); 23 | } 24 | 25 | public double getOuttakeSpeed() { 26 | return backMotor.get(); 27 | } 28 | 29 | public void setTargetOutTakeSpeed(double targetOutTakeSpeed) { 30 | this.targetOuttakeSpeed = targetOutTakeSpeed; 31 | } 32 | 33 | public double getTargetOutTakeSpeed() { 34 | return this.targetOuttakeSpeed; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /2021/04_oop/aiden_li/car.java: -------------------------------------------------------------------------------- 1 | public class Car { 2 | private String model; 3 | private String color; 4 | private int mileage = 0; 5 | private static final int MAX_MILEAGE = 20; 6 | 7 | public Car(String model, String color) { 8 | this.model = model; 9 | this.color = color; 10 | } 11 | 12 | public Car(String model) { 13 | this.model = model; 14 | this.color = colorless; 15 | } 16 | 17 | public boolean willexplode(){ 18 | return mileage >= MAX_MILEAGE; 19 | } 20 | public void repair() { 21 | System.out.println("Repaired!"); 22 | } 23 | 24 | public void explode () { 25 | System.out.println("5"); 26 | System.out.println("4"); 27 | System.out.println("3"); 28 | System.out.println("2"); 29 | System.out.println("1"); 30 | System.out.println("*explosion*"); 31 | } 32 | public void drive() { 33 | 34 | 35 | if (willexplode() == true) { 36 | explode(); 37 | }else { 38 | System.out.println("wroom"); 39 | mileage ++; 40 | 41 | } 42 | 43 | } 44 | 45 | 46 | 47 | public String toString() { 48 | return "This car is a " + color + " " + model; 49 | } 50 | } -------------------------------------------------------------------------------- /2021/04_oop/brandon_phiong/Car.java: -------------------------------------------------------------------------------- 1 | public class Car { 2 | private String model; 3 | private String color; 4 | private int mileage = 0; 5 | private static final int MAX_MILEAGE = 20; 6 | 7 | public Car(String model, String color) { 8 | this.model = model; 9 | this.color = color; 10 | } 11 | 12 | public Car(String model) { 13 | this.model = model; 14 | this.color = "colorless"; 15 | } 16 | 17 | public boolean willExplode() { 18 | return mileage >= MAX_MILEAGE; 19 | 20 | } 21 | 22 | public void repair() { 23 | mileage = 0; 24 | System.out.println("Repaired!"); 25 | } 26 | 27 | private void explode() { 28 | System.out.println("5"); 29 | System.out.println("4"); 30 | System.out.println("3"); 31 | System.out.println("2"); 32 | System.out.println("1"); 33 | System.out.println("0"); 34 | System.out.println("haha car go boom"); 35 | } 36 | 37 | public void drive() { 38 | if (willExplode()) { 39 | explode(); 40 | } else { 41 | System.out.println("vroom"); 42 | mileage++; } 43 | } 44 | 45 | public String toString() { 46 | return "This car is a " + color + " " + model; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /2021/08_newbierobot/src/main/java/frc/robot/Constants.java: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------*/ 2 | /* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ 5 | /* the project. */ 6 | /*----------------------------------------------------------------------------*/ 7 | 8 | package frc.robot; 9 | 10 | import com.stuypulse.stuylib.network.SmartNumber; 11 | 12 | /** 13 | * This contains all of the ports for motors, gamepads, etc. 14 | * 15 | * Try to avoid having random constants around your code. 16 | * 17 | * The reason its an interface is so that all the values are constant 18 | */ 19 | public interface Constants { 20 | 21 | interface Ports { 22 | interface Drivetrain { 23 | int FRONT_LEFT = 1; 24 | int FRONT_RIGHT = 3; 25 | int BACK_LEFT = 4; 26 | int BACK_RIGHT = 2; 27 | } 28 | 29 | int SHOOTER = 13; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /2020/Lesson #2/src/main/java/frc/robot/Main.java: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------*/ 2 | /* Copyright (c) 2018 FIRST. All Rights Reserved. */ 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ 5 | /* the project. */ 6 | /*----------------------------------------------------------------------------*/ 7 | 8 | package frc.robot; 9 | 10 | import edu.wpi.first.wpilibj.RobotBase; 11 | 12 | /** 13 | * Do NOT add any static variables to this class, or any initialization at all. 14 | * Unless you know what you are doing, do not modify this file except to 15 | * change the parameter class to the startRobot call. 16 | */ 17 | public final class Main { 18 | private Main() { 19 | } 20 | 21 | /** 22 | * Main initialization function. Do not perform any initialization here. 23 | * 24 | *
If you change your main robot class, change the parameter type. 25 | */ 26 | public static void main(String... args) { 27 | RobotBase.startRobot(Robot::new); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /2020/Lesson #3/src/main/java/frc/robot/Main.java: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------*/ 2 | /* Copyright (c) 2018 FIRST. All Rights Reserved. */ 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ 5 | /* the project. */ 6 | /*----------------------------------------------------------------------------*/ 7 | 8 | package frc.robot; 9 | 10 | import edu.wpi.first.wpilibj.RobotBase; 11 | 12 | /** 13 | * Do NOT add any static variables to this class, or any initialization at all. 14 | * Unless you know what you are doing, do not modify this file except to 15 | * change the parameter class to the startRobot call. 16 | */ 17 | public final class Main { 18 | private Main() { 19 | } 20 | 21 | /** 22 | * Main initialization function. Do not perform any initialization here. 23 | * 24 | *
If you change your main robot class, change the parameter type.
25 | */
26 | public static void main(String... args) {
27 | RobotBase.startRobot(Robot::new);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/2020/Lesson #3/src/main/java/frc/robot/commands/DrivetrainDriveCommand.java:
--------------------------------------------------------------------------------
1 | package frc.robot.commands;
2 |
3 | import edu.wpi.first.wpilibj.command.Command;
4 |
5 | import frc.robot.Robot;
6 | public class DrivetrainDriveCommand extends Command {
7 |
8 | public DrivetrainDriveCommand() {
9 | // Use requires() here to declare subsystem dependencies
10 | requires(Robot.drivetrain);
11 | }
12 |
13 | // Called just before this Command runs the first time
14 | @Override
15 | protected void initialize() {
16 | }
17 |
18 | // Called repeatedly when this Command is scheduled to run
19 | @Override
20 | protected void execute() {
21 | Robot.drivetrain.tankDrive(Robot.oi.gamepad.getLeftY(), Robot.oi.gamepad.getRightY());
22 | }
23 |
24 | // Make this return true when this Command no longer needs to run execute()
25 | @Override
26 | protected boolean isFinished() {
27 | return false;
28 | }
29 |
30 | // Called once after isFinished returns true
31 | @Override
32 | protected void end() {
33 | }
34 |
35 | // Called when another command which requires one or more of the same
36 | // subsystems is scheduled to run
37 | @Override
38 | protected void interrupted() {
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/2023/05_Functions/Lesson5.java:
--------------------------------------------------------------------------------
1 | public class Lesson5 {
2 | public static void main(String[] args) {
3 | }
4 | // True if even function
5 | public static boolean isEven(int n) {
6 | return n % 2 == 0;
7 | }
8 |
9 | // Avg of 3 nums
10 | public static double avg3(int a, int b, int c) {
11 | return (a + b + c) / 3.0;
12 | }
13 |
14 | // Person description function
15 | public static String personDescription(String name, int age, int grade) {
16 | return name + " is " + age + " years old and is in grade " + grade;
17 | }
18 |
19 | // Exponent function
20 | public static double exponent(double base, int power) {
21 | double result = 1;
22 | for (int i = 0; i < power; i++) {
23 | result *= base;
24 | }
25 | return result;
26 | }
27 |
28 | // Avg of 3 nums to the nth power
29 | public static double avg3ToTheNthPower(int a, int b, int c, int n) {
30 | return exponent(avg3(a, b, c), n);
31 | }
32 |
33 | // Factorial function
34 | public static int factorial(int n) {
35 | for (int i = 0; i < n; i++) {
36 | n *= i;
37 | }
38 | return n;
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/2022/RichieBot/vendordeps/WPILibNewCommands.json:
--------------------------------------------------------------------------------
1 | {
2 | "fileName": "WPILibNewCommands.json",
3 | "name": "WPILib-New-Commands",
4 | "version": "2020.0.0",
5 | "uuid": "111e20f7-815e-48f8-9dd6-e675ce75b266",
6 | "mavenUrls": [],
7 | "jsonUrl": "",
8 | "javaDependencies": [
9 | {
10 | "groupId": "edu.wpi.first.wpilibNewCommands",
11 | "artifactId": "wpilibNewCommands-java",
12 | "version": "wpilib"
13 | }
14 | ],
15 | "jniDependencies": [],
16 | "cppDependencies": [
17 | {
18 | "groupId": "edu.wpi.first.wpilibNewCommands",
19 | "artifactId": "wpilibNewCommands-cpp",
20 | "version": "wpilib",
21 | "libName": "wpilibNewCommands",
22 | "headerClassifier": "headers",
23 | "sourcesClassifier": "sources",
24 | "sharedLibrary": true,
25 | "skipInvalidPlatforms": true,
26 | "binaryPlatforms": [
27 | "linuxathena",
28 | "linuxraspbian",
29 | "linuxaarch64bionic",
30 | "windowsx86-64",
31 | "windowsx86",
32 | "linuxx86-64",
33 | "osxx86-64"
34 | ]
35 | }
36 | ]
37 | }
38 |
--------------------------------------------------------------------------------
/2021/08_newbierobot/vendordeps/WPILibNewCommands.json:
--------------------------------------------------------------------------------
1 | {
2 | "fileName": "WPILibNewCommands.json",
3 | "name": "WPILib-New-Commands",
4 | "version": "2020.0.0",
5 | "uuid": "111e20f7-815e-48f8-9dd6-e675ce75b266",
6 | "mavenUrls": [],
7 | "jsonUrl": "",
8 | "javaDependencies": [
9 | {
10 | "groupId": "edu.wpi.first.wpilibNewCommands",
11 | "artifactId": "wpilibNewCommands-java",
12 | "version": "wpilib"
13 | }
14 | ],
15 | "jniDependencies": [],
16 | "cppDependencies": [
17 | {
18 | "groupId": "edu.wpi.first.wpilibNewCommands",
19 | "artifactId": "wpilibNewCommands-cpp",
20 | "version": "wpilib",
21 | "libName": "wpilibNewCommands",
22 | "headerClassifier": "headers",
23 | "sourcesClassifier": "sources",
24 | "sharedLibrary": true,
25 | "skipInvalidPlatforms": true,
26 | "binaryPlatforms": [
27 | "linuxathena",
28 | "linuxraspbian",
29 | "linuxaarch64bionic",
30 | "windowsx86-64",
31 | "windowsx86",
32 | "linuxx86-64",
33 | "osxx86-64"
34 | ]
35 | }
36 | ]
37 | }
38 |
--------------------------------------------------------------------------------
/2022/RichieBot/src/main/java/frc/robot/commands/DriveForwardCommand.java:
--------------------------------------------------------------------------------
1 | package frc.robot.commands;
2 |
3 | import edu.wpi.first.wpilibj2.command.CommandBase;
4 | import frc.robot.subsystems.RomiDrivetrain;
5 |
6 | public class DriveForwardCommand extends CommandBase {
7 | private RomiDrivetrain drivetrain;
8 |
9 | public DriveForwardCommand(RomiDrivetrain drivetrain) {
10 | this.drivetrain = drivetrain;
11 |
12 | addRequirements(drivetrain);
13 | }
14 |
15 | // started:
16 | // 1 initialize runs once
17 | // 2 checks if isFinished() is true
18 | // 3 runs execute if not finished & goes to 2
19 | // 4 calls end if finished
20 |
21 | // initialize - runs once when command is started
22 | public void initialize() {
23 | drivetrain.stop();
24 |
25 | }
26 |
27 | // execute - runs repeatedly every 50ms until command ends
28 | public void execute() {
29 | drivetrain.tankDrive(-0.25, 0.25);
30 | }
31 |
32 | // isFinished - returns if command should end
33 | // (stop calling execute)
34 | public boolean isFinished() {
35 | return false;
36 | }
37 |
38 | // end
39 | public void end(boolean interrupted) {
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/2021/04_oop/mahir_riki/Car.java:
--------------------------------------------------------------------------------
1 | public class Car {
2 | private String model;
3 | private String color;
4 | private int mileage = 0;
5 | private static final int MAX_MILEAGE = 20;
6 |
7 | public Car(String model, String color) {
8 | this.model = model;
9 | this.color = color;
10 | }
11 |
12 | public Car(String model) {
13 | this.model = model;
14 | color = "colorless";
15 | }
16 |
17 | public void drive() {
18 | if(willExplode())
19 | explode();
20 | else {
21 | System.out.println("vroom");
22 | mileage++;
23 | }
24 |
25 | }
26 |
27 | public void repair() {
28 | mileage = 0;
29 | System.out.println("Repaired!");
30 | }
31 |
32 | public boolean willExplode() {
33 | if(mileage >= MAX_MILEAGE)
34 | return true;
35 | return false;
36 | }
37 |
38 | public void explode() {
39 | for(int i = 5; i >= 0; i--) {
40 | System.out.println(i);
41 | if(i == 0)
42 | System.out.println("haha car go boom");
43 | }
44 | }
45 |
46 | public String toString() {
47 | return "This car is a " + color + " " + model;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/2021/06_git2/group1/BenBug.java:
--------------------------------------------------------------------------------
1 | package group1;
2 |
3 | import info.gridworld.actor.Bug;
4 |
5 | public class BenBug extends Bug {
6 | int steps; // a counter for how many steps we have taken
7 | int length; // how far the bug will move
8 |
9 | public BenBug(int length) {
10 | this.steps = 0;
11 | this.length = length;
12 | }
13 |
14 | public BenBug() {
15 | this.steps = 0;
16 | this.length = 4; // 4 is the default
17 | }
18 |
19 | // this is a helper funtion
20 | // it was not in the original Bug class
21 | private void halfTurn() {
22 | for(int i = 0; i < 4; i++) {
23 | turn();
24 | }
25 | }
26 |
27 | // this method will run once every loop
28 | @Override
29 | public void act() {
30 | turn();
31 | if (steps < length) {
32 | if (canMove()) {
33 | move();
34 | steps++;
35 | } else {
36 | // turn and reset if cannot move
37 | turn();
38 | steps = 0;
39 | }
40 | } else {
41 | // half turn around and reset step counter if reached 4 steps
42 | halfTurn();
43 | steps = 0;
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/2020/Lesson #3/src/main/java/frc/robot/RobotMap.java:
--------------------------------------------------------------------------------
1 | /*----------------------------------------------------------------------------*/
2 | /* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
3 | /* Open Source Software - may be modified and shared by FRC teams. The code */
4 | /* must be accompanied by the FIRST BSD license file in the root directory of */
5 | /* the project. */
6 | /*----------------------------------------------------------------------------*/
7 |
8 | package frc.robot;
9 |
10 | /**
11 | * The RobotMap is a mapping from the ports sensors and actuators are wired into
12 | * to a variable name. This provides flexibility changing wiring, makes checking
13 | * the wiring easier and significantly reduces the number of magic numbers
14 | * floating around.
15 | */
16 | public class RobotMap {
17 | public static final int DRIVETRAIN_LEFT_FRONT_MOTOR_PORT = -1;
18 | public static final int DRIVETRAIN_RIGHT_FRONT_MOTOR_PORT = -1;
19 | public static final int DRIVETRAIN_LEFT_REAR_MOTOR_PORT = -1;
20 | public static final int DRIVETRAIN_RIGHT_REAR_MOTOR_PORT = -1;
21 |
22 | public static final int FLOOP_SOLENOID_PORT = -1;
23 | public static final int PUSHER_SOLENOID_PORT = -1;
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/2021/04_oop/dylan_hai/Car.java:
--------------------------------------------------------------------------------
1 | public class Car {
2 | private String model;
3 | private String color;
4 | private int mileage = 0;
5 | private static final int MAX_MILEAGE = 20;
6 |
7 | public Car(String model, String color) {
8 | this.model = model;
9 | this.color = color;
10 | }
11 | public Car(String model) {
12 | this.model = model;
13 | this.color = "colorless";
14 | }
15 | public void repair() {
16 | this.mileage = 0;
17 | System.out.println("Repaired!");
18 | }
19 |
20 | public String toString() {
21 | return "This car is a " + color + " " + model;
22 | }
23 | public boolean willExplode(){
24 | if (this.mileage >= this.MAX_MILEAGE){
25 | return true;
26 | }
27 | else {
28 | return false;
29 | }
30 | }
31 | private void explode(){
32 | for (int i = 5;i>0;i--){
33 | System.out.println(i);
34 | }
35 | System.out.println("haha car go boom");
36 | }
37 | public void drive(){
38 | if (willExplode()){
39 | explode();
40 | }
41 | else {
42 | System.out.println("vroom");
43 | this.mileage++;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/2021/04_oop/ivan_chen/Car.java:
--------------------------------------------------------------------------------
1 | public class Car {
2 | private String model;
3 | private String color;
4 | private int mileage = 0;
5 | private static final int MAX_MILEAGE = 20;
6 |
7 | public Car(String model, String color) {
8 | this.model = model;
9 | this.color = color;
10 | }
11 |
12 | public Car(String model) {
13 | this.model = model;
14 | this.color = "colorless";
15 | }
16 |
17 | public boolean willExplode() {
18 | return mileage >= MAX_MILEAGE;
19 | }
20 |
21 | private void explode() {
22 | System.out.println("5");
23 | System.out.println("4");
24 | System.out.println("3");
25 | System.out.println("2");
26 | System.out.println("1");
27 | System.out.println("haha car go boom");
28 | }
29 |
30 | public void drive() {
31 | if (willExplode()) {
32 | explode();
33 | } else {
34 | System.out.println("vroom");
35 | mileage++;
36 | }
37 | }
38 |
39 | public void repair() {
40 | mileage = 0;
41 | System.out.println("Repaired!");
42 | }
43 |
44 | public String toString() {
45 | return "This car is a " + color + " " + model;
46 | }
47 | }
--------------------------------------------------------------------------------
/2023/15_ControlTheory/FeedForwardController.java:
--------------------------------------------------------------------------------
1 | public class FeedForwardController extends Controller {
2 | private final double kV;
3 | private final double kA;
4 | private final double kS;
5 |
6 | public FeedForwardController(double kV, double kA, double kS) {
7 | super();
8 | this.kV = kV;
9 | this.kA = kA;
10 | this.kS = kS;
11 | }
12 |
13 | //getters for constants
14 | public double getkV() {
15 | return kV;
16 | }
17 | public double getkA() {
18 | return kA;
19 | }
20 | public double getkS() {
21 | return kS;
22 | }
23 |
24 | //you don't make setters for constants because you don't want them to change
25 |
26 | //FeedForward controller's getOutput methods (notice how there are two because sometimes you don't have acceleration)
27 | public double getOutput(double velocity, double acceleration) {
28 | return kV * velocity + kA * acceleration + kS;
29 | }
30 |
31 | @Override
32 | public double getOutput(double velocity) {
33 | return getOutput(velocity, getAcceleration(velocity));
34 | }
35 |
36 | //getAcceleration using the slope of the line between the current velocity and the previous velocity
37 | public double getAcceleration(double velocity) {
38 | return velocity / dt;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/2023/08_OOP3/Player.java:
--------------------------------------------------------------------------------
1 | public class Player {
2 | private int number;
3 | private double x;
4 | private double y;
5 | private double z;
6 |
7 | // Constructors
8 | public Player(int number, double x, double y) {
9 | this.number = number;
10 | this.x = x;
11 | this.y = y;
12 | this.z = 0; // default value of z because people are on the floor
13 | }
14 |
15 | public Player(int number, double x, double y, double z) {
16 | this.number = number;
17 | this.x = x;
18 | this.y = y;
19 | this.z = z;
20 | }
21 |
22 | public void move(double xDisp, double yDisp) {
23 | this.x += xDisp;
24 | this.y += yDisp;
25 | }
26 |
27 | public void jump(double zDisp) {
28 | this.z += zDisp;
29 | }
30 |
31 | public boolean isNear(Ball ball) {
32 | // return true if distance between player and ball is less than 8
33 | return Math.sqrt(Math.pow(this.x - ball.getX(), 2) + Math.pow(this.y - ball.getY(), 2) + Math.pow(this.z - ball.getZ(), 2)) < 8;
34 | }
35 |
36 | public void kick(Ball ball) {
37 | if (isNear(ball)) {
38 | ball.setXYZ(this.x, this.y, this.z + 5); // kicks the ball up from where the player is
39 | }
40 | else {
41 | System.out.println("Player " + this.number + " is not near the ball");
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/2023/08_OOP3/Account.java:
--------------------------------------------------------------------------------
1 | public class Account {
2 | private String id;
3 | private String name;
4 | private int balance;
5 |
6 | // Constructors
7 | public Account (String id, String name) {
8 | this.id = id;
9 | this.name = name;
10 | this.balance = 0;
11 | }
12 | public Account (String id, String name, int balance) {
13 | this.id = id;
14 | this.name = name;
15 | this.balance = balance;
16 | }
17 | // Getters
18 | public String getID() {
19 | return this.id;
20 | }
21 | public String getName() {
22 | return this.name;
23 | }
24 | public int getBalance() {
25 | return this.balance;
26 | }
27 |
28 | // Methods
29 | public int credit(int amount) {
30 | this.balance += amount;
31 | return this.balance;
32 | }
33 | public int debit(int amount) {
34 | if (this.balance >= amount) {
35 | this.balance -= amount;
36 | } else {
37 | System.out.println("Amount exceeded balance");
38 | }
39 | return this.balance;
40 | }
41 | public int transferTo(Account another, int amount) {
42 | if (this.balance >= amount) {
43 | this.balance -= amount;
44 | another.balance += amount;
45 | } else {
46 | System.out.println("Amount exceeded balance");
47 | }
48 | return this.balance;
49 | }
50 | }
--------------------------------------------------------------------------------
/2020/Lesson #3/src/main/java/frc/robot/subsystems/Floop.java:
--------------------------------------------------------------------------------
1 | /*----------------------------------------------------------------------------*/
2 | /* Copyright (c) 2018 FIRST. All Rights Reserved. */
3 | /* Open Source Software - may be modified and shared by FRC teams. The code */
4 | /* must be accompanied by the FIRST BSD license file in the root directory of */
5 | /* the project. */
6 | /*----------------------------------------------------------------------------*/
7 |
8 | package frc.robot.subsystems;
9 |
10 | import edu.wpi.first.wpilibj.Solenoid;
11 | import edu.wpi.first.wpilibj.command.Subsystem;
12 | import frc.robot.RobotMap;
13 |
14 | public class Floop extends Subsystem {
15 |
16 | private Solenoid floopSolenoid;
17 | private Solenoid pusherSolenoid;
18 |
19 | public Floop() {
20 | floopSolenoid = new Solenoid(RobotMap.FLOOP_SOLENOID_PORT);
21 | pusherSolenoid = new Solenoid(RobotMap.PUSHER_SOLENOID_PORT);
22 | }
23 |
24 | @Override
25 | public void initDefaultCommand() {
26 | //no default commands for floop
27 | }
28 |
29 | public void push() {
30 | pusherSolenoid.set(true);
31 | }
32 |
33 | public void pull() {
34 | pusherSolenoid.set(false);
35 | }
36 |
37 | public void open() {
38 | floopSolenoid.set(true);
39 | }
40 |
41 | public void close() {
42 | floopSolenoid.set(false);
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/2023/15_ControlTheory/PIDController.java:
--------------------------------------------------------------------------------
1 | public class PIDController extends Controller {
2 | //PID constants
3 | private final double kP;
4 | private final double kI;
5 | private final double kD;
6 |
7 | public PIDController(double kP, double kI, double kD) {
8 | super();
9 | this.kP = kP;
10 | this.kI = kI;
11 | this.kD = kD;
12 | }
13 |
14 | //getters for PID constants
15 | public double getkP() {
16 | return kP;
17 | }
18 | public double getkI() {
19 | return kI;
20 | }
21 | public double getkD() {
22 | return kD;
23 | }
24 |
25 | //you don't make setters for PID constants because you don't want them to change
26 |
27 | //PID controller's getOutput method
28 | @Override
29 | public double getOutput(double error) {
30 | double p = kP * error;
31 | double i = kI * integral(error);
32 | double d = kD * deriviative(error);
33 | return p + i + d;
34 | }
35 |
36 | //integral will basically find the sum of all the errors over time (area under the curve), which I simplified to error * dt
37 | public double integral(double error) {
38 | return error * this.dt;
39 | }
40 |
41 | //deriviative will find the slope of the line between the current error and the previous error, which I simplified to error / dt
42 | public double deriviative(double error) {
43 | return error / this.dt;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/2022/RichieBot/src/main/java/frc/robot/commands/ExampleCommand.java:
--------------------------------------------------------------------------------
1 | // Copyright (c) FIRST and other WPILib contributors.
2 | // Open Source Software; you can modify and/or share it under the terms of
3 | // the WPILib BSD license file in the root directory of this project.
4 |
5 | package frc.robot.commands;
6 |
7 | import frc.robot.subsystems.RomiDrivetrain;
8 | import edu.wpi.first.wpilibj2.command.CommandBase;
9 |
10 | /** An example command that uses an example subsystem. */
11 | public class ExampleCommand extends CommandBase {
12 | @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"})
13 | private final RomiDrivetrain m_subsystem;
14 |
15 | /**
16 | * Creates a new ExampleCommand.
17 | *
18 | * @param subsystem The subsystem used by this command.
19 | */
20 | public ExampleCommand(RomiDrivetrain subsystem) {
21 | m_subsystem = subsystem;
22 | // Use addRequirements() here to declare subsystem dependencies.
23 | addRequirements(subsystem);
24 | }
25 |
26 | // Called when the command is initially scheduled.
27 | @Override
28 | public void initialize() {}
29 |
30 | // Called every time the scheduler runs while the command is scheduled.
31 | @Override
32 | public void execute() {}
33 |
34 | // Called once the command ends or is interrupted.
35 | @Override
36 | public void end(boolean interrupted) {}
37 |
38 | // Returns true when the command should end.
39 | @Override
40 | public boolean isFinished() {
41 | return false;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/2021/06_git2/info/gridworld/gui/Display.java:
--------------------------------------------------------------------------------
1 | /*
2 | * AP(r) Computer Science GridWorld Case Study:
3 | * Copyright(c) 2002-2006 College Entrance Examination Board
4 | * (http://www.collegeboard.com).
5 | *
6 | * This code is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation.
9 | *
10 | * This code is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * @author Alyce Brady
16 | * @author Cay Horstmann
17 | */
18 |
19 | package info.gridworld.gui;
20 |
21 | import java.awt.Graphics2D;
22 | import java.awt.Component;
23 | import java.awt.Rectangle;
24 |
25 | /**
26 | * The \
12 | Copyright© 2002, 2007 College Entrance Examination Board \
13 | (http://www.collegeboard.com).Display interface contains the method needed to display a
27 | * grid object.
28 | * This code is not tested on the AP CS A and AB exams. It contains GUI
29 | * implementation details that are not intended to be understood by AP CS
30 | * students.
31 | */
32 | public interface Display
33 | {
34 | /**
35 | * Method invoked to draw an object.
36 | * @param obj object we want to draw
37 | * @param comp component on which to draw
38 | * @param g2 drawing surface
39 | * @param rect rectangle in which to draw
40 | */
41 | void draw(Object obj, Component c, Graphics2D g2, Rectangle rect);
42 | }
43 |
--------------------------------------------------------------------------------
/2020/Lesson #3/src/main/java/frc/robot/OI.java:
--------------------------------------------------------------------------------
1 | /*----------------------------------------------------------------------------*/
2 | /* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
3 | /* Open Source Software - may be modified and shared by FRC teams. The code */
4 | /* must be accompanied by the FIRST BSD license file in the root directory of */
5 | /* the project. */
6 | /*----------------------------------------------------------------------------*/
7 |
8 | package frc.robot;
9 |
10 | import frc.robot.commands.FloopCloseCommand;
11 | import frc.robot.commands.FloopOpenCommand;
12 | import frc.robot.commands.FloopPullCommand;
13 | import frc.robot.commands.FloopPushCommand;
14 | import frc.robot.commands.FloopStartScoreCommand;
15 | import frc.robot.commands.FloopStopScoreCommand;
16 | import frc.util.Gamepad;
17 |
18 | public class OI {
19 |
20 | public Gamepad gamepad;
21 |
22 | public OI() {
23 |
24 | gamepad = new Gamepad(0);
25 |
26 | //when each of the buttons is pressed, the corresponding command is called
27 | gamepad.getLeftButton().whenPressed(new FloopPushCommand());
28 | gamepad.getRightButton().whenPressed(new FloopPullCommand());
29 | gamepad.getTopButton().whenPressed(new FloopOpenCommand());
30 | gamepad.getBottomButton().whenPressed(new FloopCloseCommand());
31 |
32 | gamepad.getDPadLeft().whenPressed(new FloopStartScoreCommand());
33 | gamepad.getDPadRight().whenPressed(new FloopStopScoreCommand());
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/2020/Lesson #1/ExampleOne.java:
--------------------------------------------------------------------------------
1 |
2 | import java.io.FileWriter;
3 | import java.io.IOException;
4 |
5 | class ExampleOne {
6 |
7 | public static void main(String args[]) throws IOException {
8 |
9 | // This is a comment
10 | // They are green, and dont affect the code
11 |
12 | // Make a number
13 | double age = 41;
14 | boolean felon = false;
15 | String name = "Rock is an actor that does nothing. It is commonly used to
23 | * block other actors from moving.
24 | * The API of this class is testable on the AP CS A and AB exams.
25 | */
26 |
27 | public class Rock extends Actor
28 | {
29 |
30 |
31 | private static final Color DEFAULT_COLOR = Color.BLACK;
32 |
33 | /**
34 | * Constructs a black rock.
35 | */
36 | public Rock()
37 | {
38 | setColor(DEFAULT_COLOR);
39 | }
40 |
41 | /**
42 | * Constructs a rock of a given color.
43 | * @param rockColor the color of this rock
44 | */
45 | public Rock(Color rockColor)
46 | {
47 | setColor(rockColor);
48 | }
49 |
50 | /**
51 | * Overrides the act method in the Actor class
52 | * to do nothing.
53 | */
54 | public void act()
55 | {
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/2022/RichieBot/WPILib-License.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2009-2021 FIRST and other WPILib contributors
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of FIRST, WPILib, nor the names of other WPILib
12 | contributors may be used to endorse or promote products derived from
13 | this software without specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY FIRST AND OTHER WPILIB CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR
18 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR
19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
--------------------------------------------------------------------------------
/2023/09_OOP4/Lesson9.java:
--------------------------------------------------------------------------------
1 | // notice how you only import the Shooter class from the robot package because you only create objects of that class, not the AbstractRobot class
2 | import robot.Shooter;
3 |
4 | // notice how you import Car, Truck, and Vehicle from the vehicles package because you create objects of those classes
5 | import vehicles.Car;
6 | import vehicles.Truck;
7 | import vehicles.Vehicle;
8 |
9 | public class Lesson9 {
10 | public static void main(String[] args) {
11 | Vehicle[] vehicles = new Vehicle[5];
12 | vehicles[0] = new Car(1000, "Toyota", 5, "Camry");
13 | vehicles[1] = new Car(2000, "Honda", 5, "Civic");
14 | vehicles[2] = new Car(3000, "Ford", 5, "Focus");
15 | vehicles[3] = new Truck(4000, "Chevy", 2, "Bob");
16 | vehicles[4] = new Truck(5000, "Dodge", 2, "Joe");
17 | // a for-each loop, where you don't need to know the size of the array, and you don't need to use the index
18 | // (only use this when you don't need the index)
19 | for (Vehicle v : vehicles) {
20 | v.startEngine();
21 | v.stopEngine();
22 | }
23 |
24 | // Create an instance of the Shooter class
25 | Shooter shooter = new Shooter("TeamA", 123, 5.0, 45.0);
26 | // Access fields from the AbstractRobot (parent) class
27 | System.out.println("Team Name (AbstractRobot): " + shooter.getTeamName());
28 | System.out.println("Team Number (AbstractRobot): " + shooter.getTeamNumber());
29 | // Access fields from the Shooter (child) class
30 | System.out.println("Shooter Speed: " + shooter.getShooterSpeed());
31 | System.out.println("Hood Angle: " + shooter.getHoodAngle());
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/2021/06_git2/BugRunner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * AP(r) Computer Science GridWorld Case Study:
3 | * Copyright(c) 2005-2006 Cay S. Horstmann (http://horstmann.com)
4 | *
5 | * This code is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation.
8 | *
9 | * This code is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * @author Cay Horstmann
15 | */
16 |
17 | import java.util.Set;
18 |
19 | import group1.*;
20 |
21 | import info.gridworld.actor.ActorWorld;
22 | import info.gridworld.actor.Bug;
23 | import info.gridworld.actor.Rock;
24 |
25 |
26 |
27 | /**
28 | * This class runs a world that contains a bug and a rock, added at random
29 | * locations. Click on empty locations to add additional actors. Click on
30 | * populated locations to invoke methods on their occupants.
31 | * To build your own worlds, define your own actors and a runner class. See the
32 | * BoxBugRunner (in the boxBug folder) for an example.
33 | * This class is not tested on the AP CS A and AB exams.
34 | */
35 | public class BugRunner
36 | // aka bladerunner
37 | {
38 | public static void main(String[] args)
39 | {
40 | ActorWorld world = new ActorWorld();
41 |
42 |
43 | world.add(new AnthonyBug());
44 | world.add(new Bee());
45 | world.add(new BenBug());
46 | world.add(new JuanBug(5));
47 | world.add(new MommyMilkers());
48 | world.add(new SammyBug());
49 | world.add(new YasuoBug());
50 |
51 | world.show();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/2021/07_trialbyfire/Driver.java:
--------------------------------------------------------------------------------
1 | public class Driver {
2 |
3 | public static double distance(Point a, Point b){
4 | return Math.sqrt(Math.pow(a.getX()-b.getX(),2)+Math.pow(a.getY()-b.getY(),2));
5 | }
6 |
7 | public static void main(String[]args){
8 | Point p1 = new Point(1,1);
9 | Point p2 = new Point(2,2);
10 | System.out.println("Testing the distance 3 ways, should all be sqrt(2)");
11 | System.out.println(distance(p1,p2)); //static in the Driver class
12 | System.out.println(Point.distanceBetween(p1,p2)); //static in the Point class
13 | System.out.println(p1.distanceTo(p2)); //non-static in the Point class.
14 |
15 | System.out.println("\nTesting 2 identical triangles, perimeter is 2+sqrt(2)");
16 | Triangle t1 = new Triangle(0,0, 0,1, 1,0);
17 | Triangle t2 = new Triangle(new Point(0,0),new Point(0,1),new Point(1,0));
18 | System.out.println(t1);
19 | System.out.println(t1.getPerimeter());
20 | System.out.println(t2);
21 | System.out.println(t2.getPerimeter());
22 |
23 | System.out.println("\nTesting a 3/4/5 triangle");
24 | t1 = new Triangle(-1,-1, 2,3, 2,-1);
25 | System.out.println(t1);
26 | System.out.println(t1.getPerimeter());
27 |
28 | System.out.println("\nTesting getVertex in the 3/4/5 triangle");
29 | System.out.println(t1.getVertex(0));
30 | System.out.println(t1.getVertex(1));
31 | System.out.println(t1.getVertex(2));
32 |
33 | System.out.println("\nTesting setPoint in the 3/4/5 triangle");
34 | t1.setVertex(0,new Point(9,9));
35 | t1.setVertex(1,new Point(-9,9));
36 | t1.setVertex(2,new Point(9,-9));
37 | System.out.println(t1);
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/2020/Lesson #2/vendordeps/REVRobotics.json:
--------------------------------------------------------------------------------
1 | {
2 | "fileName": "REVRobotics.json",
3 | "name": "REVRobotics",
4 | "version": "1.1.9",
5 | "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb",
6 | "mavenUrls": [
7 | "http://www.revrobotics.com/content/sw/max/sdk/maven/"
8 | ],
9 | "jsonUrl": "http://www.revrobotics.com/content/sw/max/sdk/REVRobotics.json",
10 | "javaDependencies": [
11 | {
12 | "groupId": "com.revrobotics.frc",
13 | "artifactId": "SparkMax-java",
14 | "version": "1.1.9"
15 | }
16 | ],
17 | "jniDependencies": [
18 | {
19 | "groupId": "com.revrobotics.frc",
20 | "artifactId": "SparkMax-driver",
21 | "version": "1.1.9",
22 | "skipInvalidPlatforms": true,
23 | "isJar": false,
24 | "validPlatforms": [
25 | "linuxathena"
26 | ]
27 | }
28 | ],
29 | "cppDependencies": [
30 | {
31 | "groupId": "com.revrobotics.frc",
32 | "artifactId": "SparkMax-cpp",
33 | "version": "1.1.9",
34 | "libName": "libSparkMax",
35 | "headerClassifier": "headers",
36 | "sharedLibrary": false,
37 | "skipInvalidPlatforms": true,
38 | "binaryPlatforms": [
39 | "linuxathena"
40 | ]
41 | },
42 | {
43 | "groupId": "com.revrobotics.frc",
44 | "artifactId": "SparkMax-driver",
45 | "version": "1.1.9",
46 | "libName": "libSparkMaxDriver",
47 | "headerClassifier": "headers",
48 | "sharedLibrary": false,
49 | "skipInvalidPlatforms": true,
50 | "binaryPlatforms": [
51 | "linuxathena"
52 | ]
53 | }
54 | ]
55 | }
--------------------------------------------------------------------------------
/2021/05_inheritance/mahir_riki/Hero.java:
--------------------------------------------------------------------------------
1 | public class Hero {
2 | private int attack;
3 | private int currentHealth;
4 | private int maxHealth;
5 | private int resource;
6 | private int maxResource;
7 | private String resourceType;
8 | private String heroName;
9 | static int heroesMade = 0;
10 |
11 | public Hero(String heroName, int maxHealth, int attack, int maxResource, String resourceType) {
12 | this.heroName = heroName;
13 | this.maxHealth = maxHealth;
14 | this.attack = attack;
15 | this.maxResource = maxResource;
16 | this.resourceType = resourceType;
17 | heroesMade++;
18 | }
19 |
20 | public String getHeroName() {
21 | return heroName;
22 | }
23 |
24 | public int getCurrentHealth() {
25 | return currentHealth;
26 | }
27 |
28 | public int getMaxHealth() {
29 | return maxHealth;
30 | }
31 |
32 | public int getAttack() {
33 | return attack;
34 | }
35 |
36 | public int getMaxResource() {
37 | return maxResource;
38 | }
39 |
40 | public String getResourceType() {
41 | return resourceType;
42 | }
43 |
44 | public void setHeroName(String str) {
45 | heroName = str;
46 | }
47 |
48 | public void setMaxHealth(int n) {
49 | maxHealth = n;
50 | }
51 |
52 | public void setCurrentHealth(int n) {
53 | currentHealth = n;
54 | if (currentHealth > maxHealth) {
55 | setCurrentHealth(maxHealth);
56 | }
57 | }
58 |
59 | public void setAttack(int n) {
60 | attack = n;
61 | }
62 |
63 | public void setMaxResource(int n) {
64 | maxResource = n;
65 | }
66 |
67 | public void setResourceType(String str) {
68 | resourceType = str;
69 | }
70 |
71 | public void takeDamage(int n) {
72 | setCurrentHealth(getCurrentHealth() - n);
73 | }
74 |
75 | public int useAbility(String str, int n) {
76 | System.out.println(getHeroName() + "used" + str + "!");
77 | return n;
78 | }
79 | }
--------------------------------------------------------------------------------
/2021/08_newbierobot/src/main/java/frc/robot/subsystems/Drivetrain.java:
--------------------------------------------------------------------------------
1 | /*----------------------------------------------------------------------------*/
2 | /* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
3 | /* Open Source Software - may be modified and shared by FRC teams. The code */
4 | /* must be accompanied by the FIRST BSD license file in the root directory of */
5 | /* the project. */
6 | /*----------------------------------------------------------------------------*/
7 |
8 | package frc.robot.subsystems;
9 |
10 | import edu.wpi.first.wpilibj.SpeedControllerGroup;
11 | import edu.wpi.first.wpilibj.drive.DifferentialDrive;
12 | import edu.wpi.first.wpilibj2.command.SubsystemBase;
13 |
14 | import com.ctre.phoenix.motorcontrol.can.WPI_VictorSPX;
15 |
16 | import frc.robot.Constants.Ports;
17 |
18 | public class Drivetrain extends SubsystemBase {
19 |
20 | WPI_VictorSPX frontLeft = new WPI_VictorSPX(Ports.Drivetrain.FRONT_LEFT);
21 | WPI_VictorSPX backLeft = new WPI_VictorSPX(Ports.Drivetrain.BACK_LEFT);
22 | WPI_VictorSPX backRight = new WPI_VictorSPX(Ports.Drivetrain.BACK_RIGHT);
23 | WPI_VictorSPX frontRight = new WPI_VictorSPX (Ports.Drivetrain.FRONT_RIGHT);
24 |
25 | SpeedControllerGroup left = new SpeedControllerGroup(frontLeft,backLeft);
26 | SpeedControllerGroup right = new SpeedControllerGroup(frontRight,backRight);
27 |
28 | DifferentialDrive drive = new DifferentialDrive(left, right);
29 |
30 | public Drivetrain() {
31 |
32 | }
33 |
34 | public void tankDrive(double leftSpeed, double rightSpeed) {
35 | drive.tankDrive(leftSpeed, rightSpeed);
36 | }
37 |
38 | public void arcadeDrive(double speed, double turn) {
39 | drive.arcadeDrive(speed, turn);
40 | }
41 | }
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/2020/Lesson #3/src/main/java/frc/robot/Robot.java:
--------------------------------------------------------------------------------
1 | /*----------------------------------------------------------------------------*/
2 | /* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
3 | /* Open Source Software - may be modified and shared by FRC teams. The code */
4 | /* must be accompanied by the FIRST BSD license file in the root directory of */
5 | /* the project. */
6 | /*----------------------------------------------------------------------------*/
7 |
8 | package frc.robot;
9 |
10 | import edu.wpi.first.wpilibj.TimedRobot;
11 | import frc.robot.subsystems.Drivetrain;
12 | import frc.robot.subsystems.Floop;
13 | import frc.util.Gamepad;
14 |
15 | public class Robot extends TimedRobot {
16 |
17 | public static Drivetrain drivetrain;
18 | public static Floop floop;
19 | public static OI oi;
20 |
21 | @Override
22 | public void robotInit() {
23 | //creates new instance of Drivetrain object
24 | drivetrain = new Drivetrain();
25 |
26 | floop = new Floop();
27 |
28 | //makes new instance of OI (where buttons are connected with commands)
29 | oi = new OI();
30 |
31 | }
32 |
33 | @Override
34 | public void robotPeriodic() {
35 | }
36 |
37 | @Override
38 | public void disabledInit() {
39 | }
40 |
41 | @Override
42 | public void disabledPeriodic() {
43 | }
44 |
45 | @Override
46 | public void autonomousInit() {
47 | }
48 |
49 | @Override
50 | public void autonomousPeriodic() {
51 | //prints out the current tick count from the encoder
52 | //this is using the method made in Drivetrain.java
53 | System.out.println(drivetrain.getEncoderTicks());
54 | }
55 |
56 | @Override
57 | public void teleopInit() {
58 | }
59 |
60 | @Override
61 | public void teleopPeriodic() {
62 | }
63 |
64 | @Override
65 | public void testPeriodic() {
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/2021/05_inheritance/dylan_hai/Hero.java:
--------------------------------------------------------------------------------
1 | public class Hero {
2 | private int attack;
3 | private int maxHealth;
4 | private int currHealth;
5 | private int maxResource;
6 | private int currResource;
7 | public String name;
8 | private String resourceType;
9 | private static int numHeroesMade=0;
10 |
11 | public Hero(String name, int maxHealth, int attack, String resourceType, int maxResource ) {
12 | this.attack=attack;
13 | this.maxHealth=maxHealth;
14 | this.maxResource=maxResource;
15 | this.name=name;
16 | this.resourceType=resourceType;
17 | numHeroesMade++;
18 | }
19 | public void setAttack(int attack){
20 | this.attack=attack;
21 | }
22 | public int getAttack(){
23 | return this.attack;
24 | }
25 | public void setMaxHealth(int maxHealth){
26 | this.maxHealth=maxHealth;
27 | }
28 | public int getmaxHealth(){
29 | return this.maxHealth;
30 | }
31 | public void setmaxResource(int maxResource){
32 | this.maxResource=maxResource;
33 | }
34 | public int getMaxResource(){
35 | return this.maxResource;
36 | }
37 | public void setCurrResource(int currResource){
38 | this.currResource=currResource;
39 | }
40 | public int getCurrResource(){
41 | return this.currResource;
42 | }
43 | public void setName(String name){
44 | this.name=name;
45 | }
46 | public String getName(){
47 | return this.name;
48 | }
49 | public void setResourceType(String resourceType){
50 | this.resourceType=resourceType;
51 | }
52 | public String getResourceType(){
53 | return this.resourceType;
54 | }
55 | public void takeDamage(int n){
56 | this.currHealth=this.currHealth-n;
57 | }
58 | public int useAbility(String str, int n){
59 | System.out.println(this.name + " used " + str);
60 | return n;
61 | }
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/2021/06_git2/info/gridworld/actor/Flower.java:
--------------------------------------------------------------------------------
1 | /*
2 | * AP(r) Computer Science GridWorld Case Study:
3 | * Copyright(c) 2005-2006 Cay S. Horstmann (http://horstmann.com)
4 | *
5 | * This code is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation.
8 | *
9 | * This code is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * @author Cay Horstmann
15 | */
16 |
17 | package info.gridworld.actor;
18 |
19 | import java.awt.Color;
20 |
21 | /**
22 | * A Flower is an actor that darkens over time. Some actors drop
23 | * flowers as they move.
24 | * The API of this class is testable on the AP CS A and AB exams.
25 | */
26 |
27 | public class Flower extends Actor
28 | {
29 | private static final Color DEFAULT_COLOR = Color.PINK;
30 | private static final double DARKENING_FACTOR = 0.05;
31 |
32 | // lose 5% of color value in each step
33 |
34 | /**
35 | * Constructs a pink flower.
36 | */
37 | public Flower()
38 | {
39 | setColor(DEFAULT_COLOR);
40 | }
41 |
42 | /**
43 | * Constructs a flower of a given color.
44 | * @param initialColor the initial color of this flower
45 | */
46 | public Flower(Color initialColor)
47 | {
48 | setColor(initialColor);
49 | }
50 |
51 | /**
52 | * Causes the color of this flower to darken.
53 | */
54 | public void act()
55 | {
56 | Color c = getColor();
57 | int red = (int) (c.getRed() * (1 - DARKENING_FACTOR));
58 | int green = (int) (c.getGreen() * (1 - DARKENING_FACTOR));
59 | int blue = (int) (c.getBlue() * (1 - DARKENING_FACTOR));
60 |
61 | setColor(new Color(red, green, blue));
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/2021/02_git/README.md:
--------------------------------------------------------------------------------
1 | # 02_git
2 |
3 | Lesson Slides: [here](https://docs.google.com/presentation/d/1EMUmq-82oTyH2jIl2wT7KT6lPpmhIhBIWQ6qlKFcL0U/edit?usp=sharing)
4 | Recording: [here](https://drive.google.com/file/d/1mZUWKh0yP2WpUhcx5h9O63ko7zmCkMfK/view?usp=sharing)
5 |
6 | ## Assignment
7 |
8 | Create a folder using the following naming convention: `
31 | There are two ways to commit with 2fa enabled:
32 | 1. Personal Access Token: this is a password that will replace your normal password. more into [here](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token).
33 | 2. SSH key: this uses a different protocool for the remote repo called [ssh](https://www.digitalocean.com/community/tutorials/ssh-essentials-working-with-ssh-servers-clients-and-keys). more info [here](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/connecting-to-github-with-ssh).
--------------------------------------------------------------------------------
/2022/RichieBot/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id "java"
3 | id "edu.wpi.first.GradleRIO" version "2021.3.1"
4 | }
5 |
6 | sourceCompatibility = JavaVersion.VERSION_11
7 | targetCompatibility = JavaVersion.VERSION_11
8 |
9 |
10 | allprojects {
11 | repositories {
12 | maven { url 'https://jitpack.io' }
13 | }
14 | }
15 |
16 | def ROBOT_MAIN_CLASS = "frc.robot.Main"
17 |
18 | // Set this to true to enable desktop support.
19 | def includeDesktopSupport = true
20 |
21 | // Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
22 | // Also defines JUnit 4.
23 | dependencies {
24 | implementation wpi.deps.wpilib()
25 | nativeDesktopZip wpi.deps.wpilibJni(wpi.platforms.desktop)
26 |
27 |
28 | implementation wpi.deps.vendor.java()
29 | nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
30 |
31 | testImplementation 'junit:junit:4.12'
32 |
33 | // Enable simulation gui support. Must check the box in vscode to enable support
34 | // upon debugging
35 | simulation wpi.deps.sim.gui(wpi.platforms.desktop, false)
36 | simulation wpi.deps.sim.driverstation(wpi.platforms.desktop, false)
37 |
38 | // Websocket extensions require additional configuration.
39 | // simulation wpi.deps.sim.ws_server(wpi.platforms.desktop, false)
40 | simulation wpi.deps.sim.ws_client(wpi.platforms.desktop, false)
41 |
42 | implementation 'com.github.StuyPulse:StuyLib:v2021.2.2'
43 | }
44 |
45 | // Set the websocket remote host (the Romi IP address).
46 | sim {
47 | envVar "HALSIMWS_HOST", "10.6.94.2"
48 | }
49 |
50 | // Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
51 | // in order to make them all available at runtime. Also adding the manifest so WPILib
52 | // knows where to look for our Robot Class.
53 | jar {
54 | from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
55 | manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
56 | }
57 |
--------------------------------------------------------------------------------
/2021/04_oop/README.md:
--------------------------------------------------------------------------------
1 | # Exercise
2 | Edit the Car class to contain the requirements below (copy and paste the code into Car.java in your own folder (named as first_last) in this directory)
3 | ```java
4 | public class Car {
5 | private String model;
6 | private String color;
7 |
8 | public Car(String model, String color) {
9 | this.model = model;
10 | this.color = color;
11 | }
12 |
13 | public void repair() {
14 | System.out.println("Repaired!");
15 | }
16 |
17 | public String toString() {
18 | return "This car is a " + color + " " + model;
19 | }
20 | }
21 | ```
22 | 1. Add a new int field called mileage that is set to 0
23 | 2. Add a field called `private static final int MAX_MILEAGE = 20;`
24 | 3. Create a new constructor where it only takes in the model of a car and sets color to "colorless"
25 | 4. Add a method called `public boolean willExplode()` which returns whether or not a car will explode (if mileage is greater or equal to max mileage)
26 | 5. Edit the method repair() to set the mileage back to 0 and then notify us that the car is repaired
27 | 6. Add a new private method called `public void explode()` that will count down from 5 and once it reaches 0, print out `haha car go boom`
28 | 7. Add a method called `public void drive()` that if it will explode, then run explode(), and it not, print out vroom and increment the mileage by 1;
29 | 8. Test your code with this (copy and paste this into a file `Main.java` in the same directory as Car.java):
30 | ```java
31 | public class Main {
32 |
33 | public static void main(String[] args) {
34 | // hMDT stands for handMeDownToyota
35 | Car hMDT = new Car("Tesla", "fold");
36 |
37 | System.out.println("Car: " + hMDT);
38 |
39 | // Task on hand:
40 | // Check if the chair is driving too much
41 | // If it is not, continue driving it
42 | // Otherwise destroy it
43 |
44 | // boolean ab = hMDT.willExplode();
45 |
46 | while (!hMDT.willExplode()) {
47 | hMDT.drive();
48 | }
49 |
50 | System.out.println("Whew that was close. Almost exploded.");
51 | hMDT.drive();
52 | }
53 | }
54 | ```
55 |
--------------------------------------------------------------------------------
/2023/08_OOP3/Lesson8.java:
--------------------------------------------------------------------------------
1 | public class Lesson8 {
2 | public static void main(String[] args) {
3 |
4 | // Test Account class
5 | Account a1 = new Account("A101", "Elon", 1000000);
6 | Account a2 = new Account("A102", "Freshman"); // default balance
7 | // Test Getters and display info
8 | System.out.println("ID: " + a1.getID());
9 | System.out.println("Name: " + a1.getName());
10 | System.out.println("Balance: " + a1.getBalance());
11 | System.out.println("ID: " + a2.getID());
12 | System.out.println("Name: " + a2.getName());
13 | System.out.println("Balance: " + a2.getBalance());
14 | // Test credit() and debit()
15 | a1.credit(100);
16 | System.out.println("Balance: " + a1.getBalance());
17 | a1.debit(50);
18 | System.out.println("Balance: " + a1.getBalance());
19 | a2.debit(500); // debit() error because balance < amount
20 | System.out.println("Balance: " + a1.getBalance()); // balance unchanged
21 | // Test transferTo()
22 | a2.transferTo(a1, 100);
23 | System.out.println("Balance: " + a1.getBalance());
24 | System.out.println("Balance: " + a2.getBalance());
25 | a2.transferTo(a1, 1000000); // transferTo() error because balance < amount
26 | System.out.println("Balance: " + a1.getBalance());
27 | System.out.println("Balance: " + a2.getBalance());
28 |
29 | // Test Ball and Player classes
30 | Ball b1 = new Ball(0, 0, 0);
31 | Ball b2 = new Ball(10, 10, 10);
32 | Player p1 = new Player(1, 0, 0);
33 | Player p3 = new Player(3, 10, 10, 10);
34 | // Test setXYZ() and getters
35 | b1.setXYZ(1, 1, 1);
36 | System.out.println("X: " + b1.getX());
37 | System.out.println("Y: " + b1.getY());
38 | System.out.println("Z: " + b1.getZ());
39 | // Test isNear()
40 | System.out.println("Is p1 near b1? " + p1.isNear(b1)); // true because z = 0
41 | System.out.println("Is p3 near b1? " + p3.isNear(b1)); // false because z = 10
42 | // Test kick()
43 | p1.kick(b1);
44 | System.out.println("X: " + b1.getX());
45 | System.out.println("Y: " + b1.getY());
46 | System.out.println("Z: " + b1.getZ());
47 | }
48 | }
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/2021/05_inheritance/elaine_ye/Hero.java:
--------------------------------------------------------------------------------
1 | public class Hero {
2 | private String name;
3 | private int attack;
4 | private int maxHealth;
5 | private int currentHealth;
6 | private int maxResource;
7 | private int currentResource;
8 | private String resourceType;
9 | private static int heroesMade = 0;
10 |
11 | public Hero(String name, int attack, int health, int resource, String resourceType) {
12 | this.name = name;
13 | this.attack = attack;
14 | maxHealth = currentHealth = health;
15 | maxResource = currentResource = resource;
16 | this.resourceType = resourceType;
17 | heroesMade++;
18 | }
19 |
20 | public String getName(){
21 | return name;
22 | }
23 |
24 | public int getAttack() {
25 | return attack;
26 | }
27 |
28 | public int getMaxHealth() {
29 | return maxHealth;
30 | }
31 |
32 | public int getCurrentHealth() {
33 | return currentHealth;
34 | }
35 |
36 | public int getMaxResource() {
37 | return maxResource;
38 | }
39 |
40 | public int getCurrentResource() {
41 | return currentResource;
42 | }
43 |
44 | public String getResourceType() {
45 | return resourceType;
46 | }
47 |
48 | public void setName(String str) {
49 | name = str;
50 | }
51 |
52 | public void setAttack(int n) {
53 | attack = n;
54 | }
55 |
56 | public void setMaxHealth(int n) {
57 | maxHealth = n;
58 | }
59 |
60 | public void setCurrentHealth(int n) {
61 | currentHealth = n;
62 | if(getCurrentHealth() > getMaxHealth())
63 | setCurrentHealth(getMaxHealth());
64 | }
65 |
66 | public void setMaxResource(int n) {
67 | maxResource = n;
68 | }
69 |
70 | public void setCurrentResource(int n) {
71 | currentResource = n;
72 | if(getCurrentResource() > getMaxResource())
73 | setCurrentResource(getMaxResource());
74 | }
75 |
76 | public void setResourceType(String str) {
77 | resourceType = str;
78 | }
79 |
80 | public void takeDamage(int n) {
81 | setCurrentHealth(getCurrentHealth() - n);
82 | }
83 |
84 | public int useAbility(String str, int n) {
85 | System.out.println(getName() + " used " + str + "!");
86 | return n;
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/2021/05_inheritance/Eric_Lin/Hero.java:
--------------------------------------------------------------------------------
1 | public class Hero{
2 | private int atk;
3 | private int currentHP;
4 | private int maxHP;
5 | private int currentResource;
6 | private int maxResource;
7 | private String resourceType;
8 | private String name;
9 |
10 | static int heroesMade = 0;
11 | public Hero(String name, int currentHP, int maxHP, int atk, String resourceType, int currentResource, int maxResource){
12 | this.name = name;
13 | this.currentHP = currentHP;
14 | this.maxHP = maxHP;
15 | this.atk = atk;
16 | this.resourceType = resourceType;
17 | this.currentResource = currentResource;
18 | this.maxResource = maxResource;
19 | heroesMade++;
20 | }
21 | public String getName(){
22 | return name;
23 | }
24 | public int getCurrentHP(){
25 | return currentHP;
26 | }
27 | public int getMaxHP(){
28 | return maxHP;
29 | }
30 | public int getAtk(){
31 | return atk;
32 | }
33 | public String getResourceType(){
34 | return resourceType;
35 | }
36 | public int getCurrentResource(){
37 | return currentResource;
38 | }
39 | public int getMaxResource(){
40 | return maxResource;
41 | }
42 | public int takeDamage(int n){
43 | return setCurrentHP(getCurrentHP() - n);
44 | }
45 |
46 | public void setCurrentHP(int n){
47 | currentHP = n;
48 | if (getCurrentHP() > getMaxHP())
49 | setCurrentHP(getMaxHP());
50 |
51 | }
52 | public void setMaxHP(int n){
53 | maxHP = n;
54 | }
55 | public void setAtk(int n){
56 | atk = n;
57 | }
58 | public void setResourceType(String str){
59 | resourceType = str;
60 | }
61 | public void setCurrentResource(int n){
62 | currentResource = n;
63 | if (getCurrentResource() > getMaxResource())
64 | setCurrentResource(getMaxResource());
65 | }
66 | public void setMaxResource(int n){
67 | maxResource = n;
68 | }
69 |
70 | public void setName(String s){
71 | name = s;
72 | }
73 | public String useAbility(String str, int n){
74 | return System.out.println(getName() + "used" + str);
75 | }
76 |
77 |
78 |
79 | }
--------------------------------------------------------------------------------
/2021/05_inheritance/pak_lau/Hero.java:
--------------------------------------------------------------------------------
1 | public class Hero {
2 | private int attack;
3 | private int health;
4 | private int maxHealth;
5 | private int resource;
6 | private int maxResource;
7 | private String resourceType;
8 | private String name;
9 | static int heroesMade = 0;
10 |
11 | public Hero(int attack, int maxHealth, int maxResource, String resourceType, String name) {
12 | this.name = name;
13 | this.attack = attack;
14 | this.maxHealth = health = maxHealth;
15 | this.maxResource = resource = maxResource;
16 | this.resourceType = resourceType;
17 | heroesMade++;
18 | }
19 |
20 | public int getAttack() {
21 | return attack;
22 | }
23 |
24 | public int getHealth() {
25 | return health;
26 | }
27 |
28 | public int getMaxHealth() {
29 | return maxHealth;
30 | }
31 |
32 | public int getResource() {
33 | return resource;
34 | }
35 |
36 | public int getMaxResource() {
37 | return maxResource;
38 | }
39 |
40 | public String getResourceType() {
41 | return resourceType;
42 | }
43 |
44 | public String getName() {
45 | return name;
46 | }
47 |
48 | public void setAttack(int n) {
49 | attack = n;
50 | }
51 |
52 | public void setHealth(int n) {
53 | health = n;
54 | if(getHealth() > getMaxHealth())
55 | setHealth(getMaxHealth());
56 | }
57 |
58 | public void setMaxHealth(int n) {
59 | maxHealth = n;
60 | }
61 |
62 | public void setResource(int n) {
63 | resource = n;
64 | if(getResource() > getMaxResource())
65 | setResource(getMaxResource());
66 | }
67 |
68 | public void setMaxResource(int n) {
69 | maxResource = n;
70 | }
71 |
72 | public void setResourceType(String str) {
73 | resourceType = str;
74 | }
75 |
76 | public void setName(String str) {
77 | name = str;
78 | }
79 |
80 | public void takeDamage(int n) {
81 | setHealth(getHealth() - n);
82 | }
83 |
84 | public int useAbility(String str, int n) {
85 | System.out.println(getName() + " used " + str + "!");
86 | return n;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/2020/Conventions.java:
--------------------------------------------------------------------------------
1 | //
2 | // FRC Team 2910 coding conventions for the Java(tm) programming language
3 | // Note: Team 694 uses the same coding conventions, we just stole this document from them
4 | // Note 2: Actually we follow these coding conventions better than they do, because I read some of their other repos, and they cheat a lot
5 | //
6 |
7 | /*
8 | First, some basic terminology:
9 | - A class-level variable is a static variable.
10 | - A field is a non-static, member variable of a class or enum.
11 | - A constant is a final class-level variable.
12 |
13 | Always use curly braces even for single line statements.
14 | Curly braces start on the same line.
15 |
16 | Tab size is 4.
17 |
18 | Function names should be descriptive
19 | - Name a function after the action it performs.
20 | - Getters/Setters should start with "get" and "set"
21 | - Functions that return a bool should be phrased as a question.
22 | - Ex. isReady(), doesThingExist(), hasThing()
23 |
24 | Use comments and newlines to explain and organize code.
25 | Use asserts.
26 |
27 | Avoid using public member variables. Prefer to use Getters/Setters.
28 |
29 | Do not use "this." to access member variables (Ex. this.mMemberVariable)
30 | */
31 |
32 | public class ThisIsAClass { // Classes use UpperCamelCase
33 |
34 | public static final double THIS_IS_A_CONSTANT = 3.14; // Constants use UPPERCASE_WITH_UNDERSCORES
35 |
36 | private double mMemberVariable = 2.71828; // All member variables are prefixed with 'm' followed by UpperCamelCase
37 |
38 | public int getNumber() { // method names are lowerCamelCase
39 | int newVariable; // Declare one variable per line
40 | int anotherVariable; // Declare one variable per line
41 |
42 | // Always use curly braces even for single-line statements
43 | if (foo.memberFunction()) { // Curly braces start on the same line
44 | return 0;
45 | } else {
46 | return 5;
47 | }
48 | }
49 | }
50 |
51 | public enum ThisIsAnEnum { // Enums use UpperCamelCase
52 | ENUM_VALUE, // Enum values use UPPERCASE_WITH_UNDERSCORES
53 | ANOTHER_VALUE
54 | }
55 |
56 | public interface IThisIsAnInterface { // Interfaces are prefixed with a 'I' and use UpperCamelCase
57 | void doAThing();
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/2021/08_newbierobot/src/main/java/frc/robot/commands/DrivetrainDriveCommand.java:
--------------------------------------------------------------------------------
1 | package frc.robot.commands;
2 |
3 | import frc.robot.subsystems.Drivetrain;
4 |
5 | import edu.wpi.first.wpilibj2.command.CommandBase;
6 | import com.stuypulse.stuylib.input.Gamepad;
7 |
8 | public class DrivetrainDriveCommand extends CommandBase {
9 |
10 | // TODO: Make Drivetrain Drive Command
11 | private Drivetrain drivetrain;
12 | private Gamepad gamepad;
13 |
14 | public DrivetrainDriveCommand(Drivetrain drivetrain, Gamepad gamepad) {
15 | // TODO: Add requirements
16 | this.drivetrain = drivetrain;
17 | this.gamepad = gamepad;
18 |
19 | // add requirements takes in Subsystems
20 | // gamepad is not a subsystem!!! :D :O :) >:() ;-; -_- (~_~)
21 |
22 | addRequirements(drivetrain);
23 | }
24 |
25 | public void initialize() {
26 | drivetrain.tankDrive(0, 0); //looks legit
27 |
28 | }//
29 |
30 | public void execute() {
31 | double speed = gamepad.getRightTrigger() - gamepad.getLeftTrigger();
32 | double turning = gamepad.getLeftX();
33 |
34 | drivetrain.arcadeDrive(speed, turning);
35 |
36 | /*
37 | WARNING:
38 |
39 | double leftSpeed = gamepad.getLeftTrigger();
40 | double rightSpeed = gamepad.getRightTrigger();
41 | drivetrain.tankDrive(leftSpeed, rightSpeed);
42 | */
43 | }
44 |
45 |
46 | public void end(boolean interrupted) {
47 |
48 | }
49 |
50 | private static volatile boolean MY_TRUE = true;
51 | public boolean isFinished() {
52 | if (MY_TRUE == true) {
53 | return false;
54 | }
55 | else {
56 | // this is how people die
57 | // if 0 > 1 then we should die
58 | // what if a gamma ray hits the CPU while it's doing 1 > 0 and we get an unexpected value
59 | // and someone dies
60 | // that would be unfortunate but risks will be taken
61 | // someone has to bite the bullet for true production to happen (not me)
62 | // amen
63 | // amen
64 | // so sad how sam cant see this lmao
65 | //hi sam
66 | drivetrain.tankDrive(100.0, 100.0);
67 | // :(
68 | // why is sam a bully
69 | }
70 | }
71 |
72 | }
--------------------------------------------------------------------------------
/2021/06_git2/info/gridworld/gui/WorldFrameResources.properties:
--------------------------------------------------------------------------------
1 | version.id=1.00
2 | version.date=2007-04-16
3 | frame.title=GridWorld
4 | message.default=Click on a grid location to construct or manipulate an occupant.
5 | dialog.help.title=GridWorld Help
6 | dialog.help.error=Couldn't load help file.
7 | dialog.license.title=GNU Public License
8 | dialog.license.error=Couldn't load license file.
9 | dialog.about.title=About GridWorld
10 | dialog.about.text=GridWorld
\
11 | Version: {0}
Copyright© 2007 Cay S. Horstmann \
14 | (http://horstmann.com).
Images created by Chris Renard, a student at \
15 | the School for the Talented and Gifted, Dallas Independent School District.
16 | chooser.type=Select a world
17 | menu.file=&World
18 | menu.run=&Run
19 | menu.view=&Location
20 | menu.help=&Help
21 | menu.file.new=Set &grid...
22 | menu.file.new.accel=@N
23 | menu.file.save=&Save grid as...
24 | menu.file.save.accel=@S
25 | menu.file.quit=&Quit
26 | menu.file.quit.accel=@Q
27 | menu.view.zoomin=Zoom &in
28 | menu.view.zoomin.accel=@PAGE_UP
29 | menu.view.zoomout=Zoom &out
30 | menu.view.zoomout.accel=@PAGE_DOWN
31 | menu.view.left=&Left
32 | menu.view.left.accel=LEFT
33 | menu.view.right=&Right
34 | menu.view.right.accel=RIGHT
35 | menu.view.up=&Up
36 | menu.view.up.accel=UP
37 | menu.view.down=&Down
38 | menu.view.down.accel=DOWN
39 | menu.view.edit=&Edit
40 | menu.view.edit.accel=ENTER
41 | menu.view.delete=Dele&te
42 | menu.view.delete.accel=DELETE
43 | menu.view.center=&Bring (0, 0) to upper left
44 | menu.view.center.accel=@HOME
45 | menu.help.about=&About GridWorld...
46 | menu.help.help=GridWorld &Help...
47 | menu.help.help.accel=@HELP
48 | menu.help.license=View &License...
49 | button.gui.step=Step
50 | button.gui.run=Run
51 | button.gui.stop=Stop
52 | slider.gui.slow=Slow
53 | slider.gui.fast=Fast
54 | cancel=Cancel
55 | error.reason=Reason: {0}
56 | error.title=Error
57 | error.text=An error occurred.
58 | error.abort.text=An error occurred. The program must exit.
59 | cell.tooltip.nonempty={0} contains {1}
60 | cell.tooltip.empty={0} is empty
61 | dialog.method.title=Select a method
62 | dialog.constructor.title=Select a constructor
63 | dialog.method.params=Parameters
64 | dialog.method.return=Return value
65 | dialog.error.copy=Copy
--------------------------------------------------------------------------------
/2021/06_git2/info/gridworld/gui/LocationEditor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * AP(r) Computer Science GridWorld Case Study:
3 | * Copyright(c) 2005-2006 Cay S. Horstmann (http://horstmann.com)
4 | *
5 | * This code is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation.
8 | *
9 | * This code is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * @author Cay Horstmann
15 | */
16 |
17 | package info.gridworld.gui;
18 |
19 | import info.gridworld.grid.Location;
20 |
21 | import java.awt.Component;
22 | import java.beans.PropertyEditorSupport;
23 | import java.text.NumberFormat;
24 | import javax.swing.JFormattedTextField;
25 | import javax.swing.JPanel;
26 |
27 | /**
28 | * A property editor for the Location type.
29 | * This code is not tested on the AP CS A and AB exams. It contains GUI
30 | * implementation details that are not intended to be understood by AP CS
31 | * students.
32 | */
33 | public class LocationEditor extends PropertyEditorSupport
34 | {
35 | private JFormattedTextField rowField = new JFormattedTextField(NumberFormat
36 | .getIntegerInstance());
37 | private JFormattedTextField colField = new JFormattedTextField(NumberFormat
38 | .getIntegerInstance());
39 | private JPanel panel = new JPanel();
40 |
41 | public LocationEditor()
42 | {
43 | rowField.setColumns(5);
44 | colField.setColumns(5);
45 |
46 | panel.add(rowField);
47 | panel.add(colField);
48 | }
49 |
50 | public Object getValue()
51 | {
52 | int row = ((Number) rowField.getValue()).intValue();
53 | int col = ((Number) colField.getValue()).intValue();
54 | return new Location(row, col);
55 | }
56 |
57 | public void setValue(Object newValue)
58 | {
59 | Location loc = (Location) newValue;
60 | rowField.setValue(new Integer(loc.getRow()));
61 | colField.setValue(new Integer(loc.getCol()));
62 | }
63 |
64 | public boolean supportsCustomEditor()
65 | {
66 | return true;
67 | }
68 |
69 | public Component getCustomEditor()
70 | {
71 | return panel;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/2020/Lesson #2/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id "java"
3 | id "edu.wpi.first.GradleRIO" version "2019.1.1"
4 | }
5 |
6 | def ROBOT_MAIN_CLASS = "frc.robot.Main"
7 |
8 | // Define my targets (RoboRIO) and artifacts (deployable files)
9 | // This is added by GradleRIO's backing project EmbeddedTools.
10 | deploy {
11 | targets {
12 | roboRIO("roborio") {
13 | // Team number is loaded either from the .wpilib/wpilib_preferences.json
14 | // or from command line. If not found an exception will be thrown.
15 | // You can use getTeamOrDefault(team) instead of getTeamNumber if you
16 | // want to store a team number in this file.
17 | team = frc.getTeamNumber()
18 | }
19 | }
20 | artifacts {
21 | frcJavaArtifact('frcJava') {
22 | targets << "roborio"
23 | // Debug can be overridden by command line, for use with VSCode
24 | debug = frc.getDebugOrDefault(false)
25 | }
26 | // Built in artifact to deploy arbitrary files to the roboRIO.
27 | fileTreeArtifact('frcStaticFileDeploy') {
28 | // The directory below is the local directory to deploy
29 | files = fileTree(dir: 'src/main/deploy')
30 | // Deploy to RoboRIO target, into /home/lvuser/deploy
31 | targets << "roborio"
32 | directory = '/home/lvuser/deploy'
33 | }
34 | }
35 | }
36 |
37 | // Set this to true to enable desktop support.
38 | def includeDesktopSupport = false
39 |
40 | // Maven central needed for JUnit
41 | repositories {
42 | mavenCentral()
43 | }
44 |
45 | // Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
46 | // Also defines JUnit 4.
47 | dependencies {
48 | compile wpi.deps.wpilib()
49 | compile wpi.deps.vendor.java()
50 | nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
51 | nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
52 | testCompile 'junit:junit:4.12'
53 | }
54 |
55 | // Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
56 | // in order to make them all available at runtime. Also adding the manifest so WPILib
57 | // knows where to look for our Robot Class.
58 | jar {
59 | from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
60 | manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
61 | }
62 |
--------------------------------------------------------------------------------
/2020/Lesson #3/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id "java"
3 | id "edu.wpi.first.GradleRIO" version "2019.1.1"
4 | }
5 |
6 | def ROBOT_MAIN_CLASS = "frc.robot.Main"
7 |
8 | // Define my targets (RoboRIO) and artifacts (deployable files)
9 | // This is added by GradleRIO's backing project EmbeddedTools.
10 | deploy {
11 | targets {
12 | roboRIO("roborio") {
13 | // Team number is loaded either from the .wpilib/wpilib_preferences.json
14 | // or from command line. If not found an exception will be thrown.
15 | // You can use getTeamOrDefault(team) instead of getTeamNumber if you
16 | // want to store a team number in this file.
17 | team = frc.getTeamNumber()
18 | }
19 | }
20 | artifacts {
21 | frcJavaArtifact('frcJava') {
22 | targets << "roborio"
23 | // Debug can be overridden by command line, for use with VSCode
24 | debug = frc.getDebugOrDefault(false)
25 | }
26 | // Built in artifact to deploy arbitrary files to the roboRIO.
27 | fileTreeArtifact('frcStaticFileDeploy') {
28 | // The directory below is the local directory to deploy
29 | files = fileTree(dir: 'src/main/deploy')
30 | // Deploy to RoboRIO target, into /home/lvuser/deploy
31 | targets << "roborio"
32 | directory = '/home/lvuser/deploy'
33 | }
34 | }
35 | }
36 |
37 | // Set this to true to enable desktop support.
38 | def includeDesktopSupport = false
39 |
40 | // Maven central needed for JUnit
41 | repositories {
42 | mavenCentral()
43 | }
44 |
45 | // Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
46 | // Also defines JUnit 4.
47 | dependencies {
48 | compile wpi.deps.wpilib()
49 | compile wpi.deps.vendor.java()
50 | nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
51 | nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
52 | testCompile 'junit:junit:4.12'
53 | }
54 |
55 | // Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
56 | // in order to make them all available at runtime. Also adding the manifest so WPILib
57 | // knows where to look for our Robot Class.
58 | jar {
59 | from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
60 | manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
61 | }
62 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/java,macos,gradle,windows,visualstudiocode
3 | # Edit at https://www.gitignore.io/?templates=java,macos,gradle,windows,visualstudiocode
4 |
5 | ### Java ###
6 | # Compiled class file
7 | *.class
8 |
9 | # Log file
10 | *.log
11 |
12 | # BlueJ files
13 | *.ctxt
14 |
15 | # Mobile Tools for Java (J2ME)
16 | .mtj.tmp/
17 |
18 | # Package Files #
19 | *.jar
20 | *.war
21 | *.nar
22 | *.ear
23 | *.zip
24 | *.tar.gz
25 | *.rar
26 |
27 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
28 | hs_err_pid*
29 |
30 | ### macOS ###
31 | # General
32 | .DS_Store
33 | .AppleDouble
34 | .LSOverride
35 |
36 | # Icon must end with two \r
37 | Icon
38 |
39 | # Thumbnails
40 | ._*
41 |
42 | # Files that might appear in the root of a volume
43 | .DocumentRevisions-V100
44 | .fseventsd
45 | .Spotlight-V100
46 | .TemporaryItems
47 | .Trashes
48 | .VolumeIcon.icns
49 | .com.apple.timemachine.donotpresent
50 |
51 | # Directories potentially created on remote AFP share
52 | .AppleDB
53 | .AppleDesktop
54 | Network Trash Folder
55 | Temporary Items
56 | .apdisk
57 |
58 | ### VisualStudioCode ###
59 | .vscode/*
60 | !.vscode/settings.json
61 | !.vscode/tasks.json
62 | !.vscode/launch.json
63 | !.vscode/extensions.json
64 |
65 | ### VisualStudioCode Patch ###
66 | # Ignore all local history of files
67 | .history
68 |
69 | ### Windows ###
70 | # Windows thumbnail cache files
71 | Thumbs.db
72 | Thumbs.db:encryptable
73 | ehthumbs.db
74 | ehthumbs_vista.db
75 |
76 | # Dump file
77 | *.stackdump
78 |
79 | # Folder config file
80 | [Dd]esktop.ini
81 |
82 | # Recycle Bin used on file shares
83 | $RECYCLE.BIN/
84 |
85 | # Windows Installer files
86 | *.cab
87 | *.msi
88 | *.msix
89 | *.msm
90 | *.msp
91 |
92 | # Windows shortcuts
93 | *.lnk
94 |
95 | ### Gradle ###
96 | .gradle
97 | build/
98 |
99 | # Ignore Gradle GUI config
100 | gradle-app.setting
101 |
102 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
103 | !gradle-wrapper.jar
104 |
105 | # Cache of project
106 | .gradletasknamecache
107 |
108 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
109 | # gradle/wrapper/gradle-wrapper.properties
110 |
111 | ### Gradle Patch ###
112 | **/build/
113 |
114 | # End of https://www.gitignore.io/api/java,macos,gradle,windows,visualstudiocode
115 |
116 |
--------------------------------------------------------------------------------
/2021/README.md:
--------------------------------------------------------------------------------
1 | # Newbie Ed. 2021
2 |
3 | Here lives all the stuff for the 2021 newbie ed.
4 |
5 | ## Format
6 |
7 | Each dirctory is organized by lesson, with the following format: `
8 | Inside each lesson there is `README.md` with an assignment.
9 | For each assingment please make a folder for yourself like so: `
10 | If a lesson has parts they should be named so: `
11 |
12 | ### Example
13 |
14 | ```
15 | newbie-ed
16 | ├─ 2020
17 | ├─ 2021
18 | ├─ 01_cmd
19 | ├─ 02_git
20 | ├─ john_doe
21 | └─ README.md
22 | └─ README.md
23 | ├─ 03_java
24 | ├─ john_doe
25 | └─ Main.java
26 | ├─ 04_oops
27 | ├─ 05_inheritance
28 | └─ 06_git2
29 | ```
30 |
31 | ## Order
32 |
33 | The order for newbie ed can be found [here](https://docs.google.com/document/d/1B7yyqWRYecFkDHLbK46FZrSarQgD_g4x_QwnTIkw2F4/edit?usp=sharing).
34 |
35 | ## Mandatory?
36 |
37 | None of this is mandatory! The entire point is to give you Java practice as well as git practice.
38 |
39 | # How to set up Java (For Windows (x64), updated 11/03/20)
40 | (adoptopenjdk.net link is by the courtesy of our mentor, Jeanne Boyarsky)
41 |
42 | You should first check if Java is already installed with step 4 and type in `java --version` into Git Bash and make sure your version is java 11
43 | 1. Go here: https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot, and download `OpenJDK 11 (LTS)` with `HotSpot` JVM
44 | 2. Run the `OpenJDK11U-jdk_x64_windows_hotspot_11.0.9_11.msi`
45 | 1. Click `Next`
46 | 2. Check the `I accept the terms in the License Agreement` box and click `Next`
47 | 3. Click the box next to `Set JAVA_HOME variable` and click `Entire feature will be installed on local hard drive`
48 | 4. Click `Next` then `Install` and give it permission
49 | 3. To check if this worked, open (or reopen) Git Bash and type in `javac` and press `Enter`
50 | 4. If command is not found, contact an oldbie and set up a meeting with them.
51 | * The command is found if Git Bash spits out a bunch of stuff with --
52 |
53 | # How to set up Java (for all other operating systems)
54 | Go here: and follow the instruction for you specific operating system: https://adoptopenjdk.net/installation.html?variant=openjdk11&jvmVariant=hotspot (I would recommend you to use the same version and JVM as the one mentioned above)
55 |
--------------------------------------------------------------------------------
/2020/Lesson #2/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS="-Xmx64m"
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/2020/Lesson #3/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS="-Xmx64m"
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------