public DoubleInputReader newDoubleInputReader() { return new DoubleInputReader(textTerminalSupplier); }
@Override public void accept(TextIO textIO, RunnerData runnerData) { TextTerminal<?> terminal = textIO.getTextTerminal(); String initData = (runnerData == null) ? null : runnerData.getInitData(); AppUtil.printGsonMessage(terminal, initData); terminal.executeWithPropertiesPrefix("custom.title", t -> t.print("Cuboid dimensions: ")); terminal.println(); double length = textIO.newDoubleInputReader() .withMinVal(0.0) .withPropertiesPrefix("custom.length") .read("Length"); double width = textIO.newDoubleInputReader() .withMinVal(0.0) .withPropertiesPrefix("custom.width") .read("Width"); double height = textIO.newDoubleInputReader() .withMinVal(0.0) .withPropertiesPrefix("custom.height") .read("Height"); terminal.executeWithPropertiesPrefix("custom.title", t -> t.print("The volume of your cuboid is: " + length * width * height)); terminal.println(); textIO.newStringInputReader() .withMinLength(0) .withPropertiesPrefix("custom.neutral") .read("\nPress enter to terminate..."); textIO.dispose(); }
.addChoices(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); handler.addDoubleTask("unitPrice", "Unit price", true) .withInputReaderConfigurator(r -> r.withMinVal(0.01).withMaxVal(99.99)) .addChoices(0.59, 0.86, 0.99, 1.14, 1.55, 1.63, 1.74, 1.99, 2.55, 2.88, 2.99); handler.addStringTask("color", "Color", true)
@Override protected ParseResult<Double> parse(String s) { try { return new ParseResult<>(Double.parseDouble(s)); } catch (NumberFormatException e) { return new ParseResult<>(null, getErrorMessages(s)); } } }