src/Reader.java
/**
     * parses the Snake file into a Linked List of Snakeunits
     */
parses the Snake file into a Linked List of Snakeunits
parses the Snake file into a Linked List of Snakeunits
public void snake() {
        String s = null;
        try {
            s = fr.readLine();
        } catch (IOException e1) {
        }
        this.snake = new LinkedList<Snakeunit>();
        String[] head = s.split(";");
        if (head.length == 4 && head != null) {
            Snakeunit h = new Snakeunit(Integer.parseInt(head[0]), Integer.parseInt(head[1]), 
                    GameCourt.COURT_WIDTH, GameCourt.COURT_HEIGHT, Color.BLUE);
            h.setVx(Integer.parseInt(head[2]));
            h.setVy(Integer.parseInt(head[3]));
            this.head = h;
            this.snake.add(h);
        }
        try {
            s = fr.readLine();
            while (s != null && !s.isEmpty()) {
                String[] high = s.split(";");
                if (high.length != 4 || high == null) {
                    break;
                }
                Snakeunit body = 
                        new Snakeunit(Integer.parseInt(high[0]), Integer.parseInt(high[1]), 
                                GameCourt.COURT_WIDTH, GameCourt.COURT_HEIGHT, Color.GREEN);
                body.setVx(Integer.parseInt(high[2]));
                body.setVy(Integer.parseInt(high[3]));
                this.snake.add(body);
                s = fr.readLine();
            }            
        } catch (IOException e) {
        }
    }
public void snake ( ) { String s = null ; try { s = fr . readLine ( ) ; } catch ( IOException e1 ) { } this . snake = new LinkedList < Snakeunit > ( ) ; String [ ] head = s . split ( ";" ) ; if ( head . length == 4 && head != null ) { Snakeunit h = new Snakeunit ( Integer . parseInt ( head [ 0 ] ) , Integer . parseInt ( head [ 1 ] ) , GameCourt . COURT_WIDTH , GameCourt . COURT_HEIGHT , Color . BLUE ) ; h . setVx ( Integer . parseInt ( head [ 2 ] ) ) ; h . setVy ( Integer . parseInt ( head [ 3 ] ) ) ; this . head = h ; this . snake . add ( h ) ; } try { s = fr . readLine ( ) ; while ( s != null && ! s . isEmpty ( ) ) { String [ ] high = s . split ( ";" ) ; if ( high . length != 4 || high == null ) { break ; } Snakeunit body = new Snakeunit ( Integer . parseInt ( high [ 0 ] ) , Integer . parseInt ( high [ 1 ] ) , GameCourt . COURT_WIDTH , GameCourt . COURT_HEIGHT , Color . GREEN ) ; body . setVx ( Integer . parseInt ( high [ 2 ] ) ) ; body . setVy ( Integer . parseInt ( high [ 3 ] ) ) ; this . snake . add ( body ) ; s = fr . readLine ( ) ; } } catch ( IOException e ) { } }
parses the Snake file into a Linked List of Snakeunits
parses the Snake file into a Linked List of Snakeunits