From: Cindy Zhang Date: Thu, 19 Jan 2017 05:05:07 +0000 (-0800) Subject: implement singleton pattern for climber and shooter subsystems X-Git-Url: http://challenge-bot.com/repos/?p=3501%2F2017steamworks;a=commitdiff_plain;h=079a8cb65ad4cfca3d0f01f1af424e6bd97c8bc9 implement singleton pattern for climber and shooter subsystems --- diff --git a/src/org/usfirst/frc/team3501/robot/Robot.java b/src/org/usfirst/frc/team3501/robot/Robot.java index 8e98834..5fbfe40 100644 --- a/src/org/usfirst/frc/team3501/robot/Robot.java +++ b/src/org/usfirst/frc/team3501/robot/Robot.java @@ -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)); diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java index 759a232..3df4f7d 100644 --- a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java @@ -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() { + + } }