protected Integer getIntegerField(String fieldName) {
        Integer i;
        while (true) {
            try {
                i = io.getInteger(fieldName + ": ");
                break;
            } catch (NumberFormatException ex) {
                io.println("Invalid number!");
                continue;
            }
        }
        return i;
    }