public static String[] getValidTwoDigits(String currencyCode) throws InterruptOperationException { String[] array; writeMessage( String.format(res.getString("choose.denomination.and.count.format"), currencyCode)); while (true) { String s = readString(); array = s.split(" "); int k; int l; try { k = Integer.parseInt(array[0]); l = Integer.parseInt(array[1]); } catch (Exception e) { writeMessage(res.getString("invalid.data")); continue; } if (k <= 0 || l <= 0 || array.length > 2) { writeMessage(res.getString("invalid.data")); continue; } break; } return array; }
public static String[] getValidTwoDigits(String currencyCode) throws InterruptOperationException { while (true) { writeMessage(res.getString("choose.denomination.and.count.format")); String twoNumbers = readString(); String[] numbers; if (twoNumbers != null) { numbers = twoNumbers.split(" "); } else { writeMessage(res.getString("invalid.data")); continue; } if (numbers.length != 2) { writeMessage(res.getString("invalid.data")); continue; } if (isInteger(numbers[0]) && isInteger(numbers[1]) && Integer.parseInt(numbers[0]) > 0 && Integer.parseInt(numbers[1]) > 0) { return numbers; } else { writeMessage(res.getString("invalid.data")); } } }
@Override public void execute() throws InterruptOperationException { ConsoleHelper.writeMessage(res.getString("exit.question.y.n")); if (ConsoleHelper.readString().equals(res.getString("yes"))) { ConsoleHelper.writeMessage(res.getString("thank.message")); } }
public static String askCurrencyCode() throws InterruptOperationException { while (true) { writeMessage(res.getString("choose.currency.code")); String currencyCode = readString(); if (currencyCode != null && currencyCode.length() == 3) { return currencyCode.toUpperCase(); } writeMessage(res.getString("invalid.data")); } }
public static String askCurrencyCode() throws InterruptOperationException { String test; writeMessage(res.getString("choose.currency.code")); while (true) { test = readString(); if (test.length() == 3) break; else writeMessage(res.getString("invalid.data")); } test = test.toUpperCase(); return test; }
@Override public void execute() { Collection<CurrencyManipulator> factory = CurrencyManipulatorFactory.getAllCurrencyManipulators(); if (factory.isEmpty()) ConsoleHelper.writeMessage(res.getString("no.money")); else { for (CurrencyManipulator manipulator : factory) { if (!manipulator.hasMoney()) ConsoleHelper.writeMessage(res.getString("no.money")); else ConsoleHelper.writeMessage( manipulator.getCurrencyCode() + " - " + manipulator.getTotalAmount()); } } }
public static Operation askOperation() throws InterruptOperationException { while (true) { String line = readString(); if (checkWithRegExp(line)) return Operation.getAllowableOperationByOrdinal(Integer.parseInt(line)); else writeMessage(res.getString("invalid.data")); } }
public static Integer askSum() throws InterruptOperationException { while (true) { String sum = readString(); if (isInteger(sum)) { return Integer.parseInt(sum); } else { writeMessage(res.getString("invalid.data")); } } }
public static Operation askOperation() throws InterruptOperationException { writeMessage(res.getString("choose.operation")); String op = readString(); while (true) { if (op == null) { continue; } if (!isInteger(op)) { continue; } int num = Integer.parseInt(op); return Operation.getAllowableOperationByOrdinal(num); } }
public static void printExitMessage() { ConsoleHelper.writeMessage(res.getString("the.end")); }
public static void printExitMessage() { ConsoleHelper.writeMessage("Bye!"); }