implement singleton pattern for climber and shooter subsystems
authorCindy Zhang <cindyzyx9@gmail.com>
Thu, 19 Jan 2017 05:05:07 +0000 (21:05 -0800)
committerCindy Zhang <cindyzyx9@gmail.com>
Thu, 19 Jan 2017 05:05:07 +0000 (21:05 -0800)
src/org/usfirst/frc/team3501/robot/Robot.java
src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java

index 8e98834a47f60a7d2e50b9f4b12d9a31b934afea..5fbfe4043d6b58bca46b2daffc35783c2ae74251 100644 (file)
@@ -1,7 +1,9 @@
 package org.usfirst.frc.team3501.robot;
 
 import org.usfirst.frc.team3501.robot.commands.driving.TimeDrive;
+import org.usfirst.frc.team3501.robot.subsystems.Climber;
 import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
+import org.usfirst.frc.team3501.robot.subsystems.Shooter;
 
 import edu.wpi.first.wpilibj.IterativeRobot;
 import edu.wpi.first.wpilibj.command.Scheduler;
@@ -9,11 +11,16 @@ import edu.wpi.first.wpilibj.command.Scheduler;
 public class Robot extends IterativeRobot {
   private static DriveTrain driveTrain;
   private static OI oi;
+  private static Climber climber;
+  private static Shooter shooter;
 
   @Override
   public void robotInit() {
     driveTrain = DriveTrain.getDriveTrain();
     oi = OI.getOI();
+    climber = Climber.getClimber();
+    shooter = Shooter.getShooter();
+
   }
 
   public static DriveTrain getDriveTrain() {
@@ -24,6 +31,14 @@ public class Robot extends IterativeRobot {
     return OI.getOI();
   }
 
+  public static Climber getClimber() {
+    return Climber.getClimber();
+  }
+
+  public static Shooter getShooter() {
+    return Shooter.getShooter();
+  }
+
   @Override
   public void autonomousInit() {
     Scheduler.getInstance().add(new TimeDrive(1.5, 0.4));
index 759a232e443617a67715c80ccc09c9fe6ff1e0cd..3df4f7d29516f40c3df7e7c2ce871ab10484e6d5 100644 (file)
@@ -1,59 +1,68 @@
 package org.usfirst.frc.team3501.robot.subsystems;
 
 public class Shooter {
-       public Shooter() {
+  private static Shooter shooter;
 
-       }
+  private Shooter() {
 
-       /**
-        * Stops fly wheel
-        */
-       public void stopFlywheel() {
+  }
 
-       }
+  public static Shooter getShooter() {
+    if (shooter == null) {
+      shooter = new Shooter();
+    }
+    return shooter;
+  }
 
-       /**
-        * Runs the fly wheel at a given speed in () for input time in seconds
-        *
-        * @param speed
-        *            in ()
-        * @param time
-        *            in seconds
-        */
-       public void runFlywheel(double speed, double time) {
+  /**
+   * Stops fly wheel
+   */
+  public void stopFlywheel() {
 
-       }
+  }
 
-       /**
-        * Stops index wheel
-        */
-       public void stopIndexWheel() {
+  /**
+   * Runs the fly wheel at a given speed in () for input time in seconds
+   *
+   * @param speed
+   *          in ()
+   * @param time
+   *          in seconds
+   */
+  public void runFlywheel(double speed, double time) {
 
-       }
+  }
 
-       /**
-        * Runs index wheel at a given speed in () for input time in seconds
-        *
-        * @param speed
-        *            in ()
-        * @param time
-        *            in seconds
-        */
-       public void runIndexWheel(double speed, double time) {
+  /**
+   * Stops index wheel
+   */
+  public void stopIndexWheel() {
 
-       }
+  }
 
-       /**
-        * Runs fly wheel continuously until ________
-        */
-       public void runFlywheelContinuous() {
+  /**
+   * Runs index wheel at a given speed in () for input time in seconds
+   *
+   * @param speed
+   *          in ()
+   * @param time
+   *          in seconds
+   */
+  public void runIndexWheel(double speed, double time) {
 
-       }
+  }
 
-       /**
-        * Runs index wheel continuously until ________
-        */
-       public void runIndexWheelContinuous() {
+  /**
+   * Runs fly wheel continuously until ________
+   */
+  public void runFlywheelContinuous() {
 
-       }
+  }
+
+  /**
+   * Runs index wheel continuously until ________
+   */
+  public void runIndexWheelContinuous() {
+
+  }
 }