String[] setMethodNames={"FirstName","LastName","Street"}; Class cls = Class.forName("<qualifiedname>Contestant"); Class parameterTypes = String.class; for(String s:setMethodNames){ do{ try{ flag=false; System.out.println("Please enter your "+s+" :"); String inp=scanner.nextLine(); cls.getDeclaredMethod("set"+s, parameterTypes ).invoke(contestant1, inp); }catch(InvalidInputException e){ System.out.println(e.getMessage()); flag = true; } }while(flag); }
public static boolean isDigit(char c) throws InvalidInputException { if(c < ScannerHelper.MAX_OBVIOUS) { return (ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_DIGIT) != 0; } if (Character.isDigit(c)) { throw new InvalidInputException(Scanner.INVALID_DIGIT); } return false; } public static int digit(char c, int radix) {
public static boolean isDigit(char c) throws InvalidInputException { if(c < ScannerHelper.MAX_OBVIOUS) { return (ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_DIGIT) != 0; } if (Character.isDigit(c)) { throw new InvalidInputException(Scanner.INVALID_DIGIT); } return false; } public static int digit(char c, int radix) {
List<String> labels = Arrays.asList( "Please enter your first name.", "Please enter your last name.", "Please enter your street number." ); Function<String, Void> setters = Arrays.asList( contestant1::setName, contestant1::setLastName, contestant1::setStreetNumber ); Iterator<String> label = labels.iterator(); for(Function<String, Void> setter : setters) { do { try { flag = false; System.out.println(label.next()); String value = Scanner.nextLine(); setter.apply(value); } catch (InvalidInputException e) { System.out.println(e.getMessage()); flag = true; } } while (flag); }
public static boolean isDigit(char c) throws InvalidInputException { if(c < ScannerHelper.MAX_OBVIOUS) { return (ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_DIGIT) != 0; } if (Character.isDigit(c)) { throw new InvalidInputException(Scanner.INVALID_DIGIT); } return false; } public static int digit(char c, int radix) {
callSetFunction(contestant1,s,inp); }catch(InvalidInputException e){ System.out.println(e.getMessage()); flag = true;
public static boolean isDigit(char c) throws InvalidInputException { if(c < ScannerHelper.MAX_OBVIOUS) { return (ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_DIGIT) != 0; } if (Character.isDigit(c)) { throw new InvalidInputException(Scanner.INVALID_DIGIT); } return false; } public static int digit(char c, int radix) {
/** * Reads the next token. * @param ignoreComments If set, comments will be overread. * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ private int readNextWithEOF(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= fScanner.getNextToken(); } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
public static boolean isDigit(char c) throws InvalidInputException { if(c < ScannerHelper.MAX_OBVIOUS) { return (ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_DIGIT) != 0; } if (Character.isDigit(c)) { throw new InvalidInputException(Scanner.INVALID_DIGIT); } return false; } public static int digit(char c, int radix) {
/** * Reads the next token. * @param ignoreComments If set, comments will be overread. * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ private int readNextWithEOF(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= fScanner.getNextToken(); } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
public static boolean isDigit(char c) throws InvalidInputException { if(c < ScannerHelper.MAX_OBVIOUS) { return (ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_DIGIT) != 0; } if (Character.isDigit(c)) { throw new InvalidInputException(Scanner.INVALID_DIGIT); } return false; } public static int digit(char c, int radix) {
/** * Reads the next token. * @param ignoreComments If set, comments will be overread. * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ private int readNextWithEOF(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= fScanner.getNextToken(); } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
public static boolean isDigit(char c) throws InvalidInputException { if(c < ScannerHelper.MAX_OBVIOUS) { return (ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_DIGIT) != 0; } if (Character.isDigit(c)) { throw new InvalidInputException(Scanner.INVALID_DIGIT); } return false; } public static int digit(char c, int radix) {
/** * Reads the next token. * @param ignoreComments If set, comments will be overread * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ public int readNext(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= fScanner.getNextToken(); if (curr == ITerminalSymbols.TokenNameEOF) { throw new CoreException(createError(END_OF_FILE, "End Of File", null)); //$NON-NLS-1$ } } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
public static boolean isDigit(char c) throws InvalidInputException { if(c < ScannerHelper.MAX_OBVIOUS) { return (ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_DIGIT) != 0; } if (Character.isDigit(c)) { throw new InvalidInputException(Scanner.INVALID_DIGIT); } return false; } public static int digit(char c, int radix) {
/** * Reads the next token. * @param ignoreComments If set, comments will be overread * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ public int readNext(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= this.scanner.getNextToken(); if (curr == TerminalTokens.TokenNameEOF) { throw new CoreException(createError(END_OF_FILE, "End Of File", null)); //$NON-NLS-1$ } } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
public static boolean isDigit(char c) throws InvalidInputException { if(c < ScannerHelper.MAX_OBVIOUS) { return (ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_DIGIT) != 0; } if (Character.isDigit(c)) { throw new InvalidInputException(Scanner.INVALID_DIGIT); } return false; } public static int digit(char c, int radix) {
/** * Reads the next token. * @param ignoreComments If set, comments will be overread * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ public int readNext(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= this.scanner.getNextToken(); if (curr == TerminalTokens.TokenNameEOF) { throw new CoreException(createError(END_OF_FILE, "End Of File", null)); //$NON-NLS-1$ } } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
public static boolean isDigit(char c) throws InvalidInputException { if(c < ScannerHelper.MAX_OBVIOUS) { return (ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_DIGIT) != 0; } if (Character.isDigit(c)) { throw new InvalidInputException(Scanner.INVALID_DIGIT); } return false; } public static int digit(char c, int radix) {
/** * Reads the next token. * @param ignoreComments If set, comments will be overread * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ public int readNext(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= this.scanner.getNextToken(); if (curr == TerminalTokens.TokenNameEOF) { throw new CoreException(createError(END_OF_FILE, "End Of File", null)); //$NON-NLS-1$ } } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }