src/main/java/se/kth/iv1351/weatherstat/view/BlockingInterpreter.java
/**
     * Interprets and performs user commands. This method will not return until the
     * UI has been stopped. The UI is stopped either when the user gives the "quit"
     * command, or when the method <code>stop()</code> is called.
     */
Interprets and performs user commands. This method will not return until the
UI has been stopped. The UI is stopped either when the user gives the "quit"
command, or when the method stop() is called.
Interprets and performs user commands . This method will not return until the UI has been stopped . The UI is stopped either when the user gives the " quit " command or when the method stop () is called .
public void handleCmds() {
        keepReceivingCmds = true;
        while (keepReceivingCmds) {
            try {
                CmdLine cmdLine = new CmdLine(readNextLine());
                switch (cmdLine.getCmd()) {
                    case HELP:
                        for (Command command : Command.values()) {
                            if (command == Command.ILLEGAL_COMMAND) {
                                continue;
                            }
                            System.out.println(command.toString().toLowerCase());
                        }
                        break;
                    case QUIT:
                        keepReceivingCmds = false;
                        break;
                    case LOAD:
                        ctrl.loadFromAllApis();
                        break;
                    case START:
                        ctrl.startHourlyLoading();
                        break;
                    case STOP:
                        ctrl.stopHourlyLoading();
                        break;
                    case AVG:
                        System.out.println(String.format("%.2f", ctrl.getAverageTemp()) + " \u00B0C");
                        break;
                    default:
                        System.out.println("illegal command");
                }
            } catch (Exception e) {
                LOGGER.error("Operation failed");
                LOGGER.error(e.getMessage(), e);
            }
        }
    }
public void handleCmds ( ) { keepReceivingCmds = true ; while ( keepReceivingCmds ) { try { CmdLine cmdLine = new CmdLine ( readNextLine ( ) ) ; switch ( cmdLine . getCmd ( ) ) { case HELP : for ( Command command : Command . values ( ) ) { if ( command == Command . ILLEGAL_COMMAND ) { continue ; } System . out . println ( command . toString ( ) . toLowerCase ( ) ) ; } break ; case QUIT : keepReceivingCmds = false ; break ; case LOAD : ctrl . loadFromAllApis ( ) ; break ; case START : ctrl . startHourlyLoading ( ) ; break ; case STOP : ctrl . stopHourlyLoading ( ) ; break ; case AVG : System . out . println ( String . format ( "%.2f" , ctrl . getAverageTemp ( ) ) + " \u00B0C" ) ; break ; default : System . out . println ( "illegal command" ) ; } } catch ( Exception e ) { LOGGER . error ( "Operation failed" ) ; LOGGER . error ( e . getMessage ( ) , e ) ; } } }
Interprets and performs user commands.
Interprets and performs user commands .