All pastes #431378 Raw Edit

Stuff

public java v1 · immutable
·published 2007-04-09 16:47 UTC
rendered paste body
/** * * @author mario */public class SocketProtocol {        MediaPlayer Play = new MediaPlayer();    private static final int WAITING = 0;    private static final int SENTKNOCKKNOCK = 1;    private static final int SENTCLUE = 2;    private static final int ANOTHER = 3;        private int state = WAITING;    public String processInput(String theInput) {        String theOutput = null;                        if (theInput.equalsIgnoreCase("play2")) {            System.out.println("play");        }                if (theInput.equalsIgnoreCase("pause")) {            System.out.println("play");        }                        System.out.println("First Step");                if (state == WAITING) {                        theOutput = "Knock! Knock!";            state = SENTKNOCKKNOCK;        } else if (state == SENTKNOCKKNOCK) {            if (theInput.equalsIgnoreCase("play")) {                Play.PlayFile();                state = SENTCLUE;            } else {                theOutput = "You're supposed to say \"Who's there?\"! " +                        "Try again. Knock! Knock!";            }        } else if (state == SENTCLUE) {            if (theInput.equalsIgnoreCase("pause")) {                Play.SendCommand("pause\n");                state = ANOTHER;            } else {                theOutput = "foo";                state = SENTKNOCKKNOCK;            }        } else if (state == ANOTHER) {            if (theInput.equalsIgnoreCase("y")) {                theOutput = "Knock! Knock!";            } else {                theOutput = "Bye.";                state = WAITING;            }        }        return theOutput;    }    }