All pastes #957685 Raw Edit

Unnamed

public java v1 · immutable
#957685 ·published 2008-03-26 03:20 UTC
rendered paste body
public class Main {    public static void main(String[] args) {        new Main().init();    }    /**     * First function that is being run     */    private void init() {        Console c = System.console();        boolean running = true;        // Reads user input in a loop        while (running) {             String direction = c.readLine();            // if LEFT hand the direction over to the handler            if (direction.equals("LEFT")) {                Direction d = Direction.LEFT;                handler(d);            } else if (direction.equals("RIGHT")) {            } else if (direction.equals("QUIT")) {                running = false;                System.exit(0);            }        }    }    /**     * Handler that updates the model     * @param h     */    private void handler(Direction h) {        switch (h) {            case LEFT:                System.out.println("Moving left (Also validates move etc.)");                System.out.println("Print model and message");            case RIGHT:                System.out.println("Moving right --");                System.out.println("Print model and message");        }    }    enum Direction {        LEFT, RIGHT, TOP, BOTTOM;    }}