001/*----------------------------------------------------------------------------*/
002/* Copyright (c) FIRST 2008-2012. All Rights Reserved.                        */
003/* Open Source Software - may be modified and shared by FRC teams. The code   */
004/* must be accompanied by the FIRST BSD license file in the root directory of */
005/* the project.                                                               */
006/*----------------------------------------------------------------------------*/
007
008package edu.wpi.first.wpilibj.command;
009
010/**
011 * A {@link PrintCommand} is a command which prints out a string when it is initialized, and then immediately finishes.
012 * It is useful if you want a {@link CommandGroup} to print out a string when it reaches a certain point.
013 *
014 * @author Joe Grinstead
015 */
016public class PrintCommand extends Command {
017
018    /** The message to print out */
019    private String message;
020
021    /**
022     * Instantiates a {@link PrintCommand} which will print the given message when it is run.
023     * @param message the message to print
024     */
025    public PrintCommand(String message) {
026        super("Print(\"" + message + "\"");
027        this.message = message;
028    }
029
030    protected void initialize() {
031        System.out.println(message);
032    }
033
034    protected void execute() {
035    }
036
037    protected boolean isFinished() {
038        return true;
039    }
040
041    protected void end() {
042    }
043
044    protected void interrupted() {
045    }
046}