monkey-island/src/fr/eseo/game/network/MonkeyIsland.java
private void switchCommand(Command command) throws IndexOutOfBoundsException {
            Pirate pirate = null;
            switch (command.getCommandEnum()) {

                case NEW_PIRATE_CLIENT:
                    pirate = island.addPirate(this.com.getPort());
                    if (pirate != null) {
                        this.com.sendMessage(PIRATE, pirate.toStringWithEnergyAndId());
                        System.out.println(this + "Pirate has been created.");
                    } else {
                        System.err.println(this + "Pirate has already been created.");
                    }
                    break;

                case MOVE_PIRATE_CLIENT:
                    List<Integer> list = command.getValues();
                    pirate = island.movePirate(this.com.getPort(), list.get(0), list.get(1));
                    if (pirate != null) {
                        this.com.sendMessage(CORRECT_MOVE, pirate.toStringWithEnergy());
                        System.out.println(this + "Pirate has been moved.");
                    } else {
                        this.com.sendMessage(INCORRECT_MOVE.toString());
                        System.err.println(this + "Can't move your pirate.");
                    }
                    break;

                default:
                    System.err.println("Not implemented yet");
                    break;
            }
        }
/**
         * Switch command on receiving a message.
         * @param command Command param.
         * @throws IndexOutOfBoundsException For index bound exception.
         */
Switch command on receiving a message.
@param command Command param.
@throws IndexOutOfBoundsException For index bound exception.
Switch command on receiving a message . @param command Command param . @throws IndexOutOfBoundsException For index bound exception .
private void switchCommand(Command command) throws IndexOutOfBoundsException {
            Pirate pirate = null;
            switch (command.getCommandEnum()) {
                case NEW_PIRATE_CLIENT:
                    pirate = island.addPirate(this.com.getPort());
                    if (pirate != null) {
                        this.com.sendMessage(PIRATE, pirate.toStringWithEnergyAndId());
                        System.out.println(this + "Pirate has been created.");
                    } else {
                        System.err.println(this + "Pirate has already been created.");
                    }
                    break;
                case MOVE_PIRATE_CLIENT:
                    List<Integer> list = command.getValues();
                    pirate = island.movePirate(this.com.getPort(), list.get(0), list.get(1));
                    if (pirate != null) {
                        this.com.sendMessage(CORRECT_MOVE, pirate.toStringWithEnergy());
                        System.out.println(this + "Pirate has been moved.");
                    } else {
                        this.com.sendMessage(INCORRECT_MOVE.toString());
                        System.err.println(this + "Can't move your pirate.");
                    }
                    break;
                default:
                    System.err.println("Not implemented yet");
                    break;
            }
        }
private void switchCommand ( Command command ) throws IndexOutOfBoundsException { Pirate pirate = null ; switch ( command . getCommandEnum ( ) ) { case NEW_PIRATE_CLIENT : pirate = island . addPirate ( this . com . getPort ( ) ) ; if ( pirate != null ) { this . com . sendMessage ( PIRATE , pirate . toStringWithEnergyAndId ( ) ) ; System . out . println ( this + "Pirate has been created." ) ; } else { System . err . println ( this + "Pirate has already been created." ) ; } break ; case MOVE_PIRATE_CLIENT : List < Integer > list = command . getValues ( ) ; pirate = island . movePirate ( this . com . getPort ( ) , list . get ( 0 ) , list . get ( 1 ) ) ; if ( pirate != null ) { this . com . sendMessage ( CORRECT_MOVE , pirate . toStringWithEnergy ( ) ) ; System . out . println ( this + "Pirate has been moved." ) ; } else { this . com . sendMessage ( INCORRECT_MOVE . toString ( ) ) ; System . err . println ( this + "Can't move your pirate." ) ; } break ; default : System . err . println ( "Not implemented yet" ) ; break ; } }
Switch command on receiving a message.
Switch command on receiving a message .