src/main/java/com/xdavide9/calculatorfx/CalculatorFXController.java
@FXML
    protected void OnNumberPressed(ActionEvent e) {
        id = updateId(e);
        log.info("Pressed: {}", id);

        onLabel = label.getText();
        if (status(onLabel) == -1) return;

        if (onLabel.equals("0"))
            builder = new StringBuilder();

        switch (id) {
            case "zeroButton" ->  {
                if (onLabel.startsWith("0") && (!onLabel.contains("."))) {
                    log.error("Cannot append 0");
                    return;
                }
                builder.append(0);
            }
            case "oneButton" -> builder.append(1);
            case "twoButton" -> builder.append(2);
            case "threeButton" -> builder.append(3);
            case "fourButton" -> builder.append(4);
            case "fiveButton" -> builder.append(5);
            case "sixButton" -> builder.append(6);
            case "sevenButton" -> builder.append(7);
            case "eightButton" -> builder.append(8);
            case "nineButton" -> builder.append(9);
            case "piButton" -> {
                builder = new StringBuilder();
                builder.append(round(BigDecimal.valueOf(Math.PI)));
            }
            case "eButton" -> {
                builder = new StringBuilder();
                builder.append(round(BigDecimal.valueOf(Math.E)));
            }
        }

        onLabel = builder.toString();
        if (hasTooManyDigits(onLabel.length())) {
            log.error("Maximum limit of digits reached");
            onLabel = onLabel.substring(0, maxDigits);
        }

        label.setText(onLabel);
    }
/**
     * Appends to the label the number of the corresponding button
     * respecting the limit of maximum digits allowed.
     */
Appends to the label the number of the corresponding button
respecting the limit of maximum digits allowed.
Appends to the label the number of the corresponding button respecting the limit of maximum digits allowed .
@FXML
    protected void OnNumberPressed(ActionEvent e) {
        id = updateId(e);
        log.info("Pressed: {}", id);
        onLabel = label.getText();
        if (status(onLabel) == -1) return;
        if (onLabel.equals("0"))
            builder = new StringBuilder();
        switch (id) {
            case "zeroButton" ->  {
                if (onLabel.startsWith("0") && (!onLabel.contains("."))) {
                    log.error("Cannot append 0");
                    return;
                }
                builder.append(0);
            }
            case "oneButton" -> builder.append(1);
            case "twoButton" -> builder.append(2);
            case "threeButton" -> builder.append(3);
            case "fourButton" -> builder.append(4);
            case "fiveButton" -> builder.append(5);
            case "sixButton" -> builder.append(6);
            case "sevenButton" -> builder.append(7);
            case "eightButton" -> builder.append(8);
            case "nineButton" -> builder.append(9);
            case "piButton" -> {
                builder = new StringBuilder();
                builder.append(round(BigDecimal.valueOf(Math.PI)));
            }
            case "eButton" -> {
                builder = new StringBuilder();
                builder.append(round(BigDecimal.valueOf(Math.E)));
            }
        }
        onLabel = builder.toString();
        if (hasTooManyDigits(onLabel.length())) {
            log.error("Maximum limit of digits reached");
            onLabel = onLabel.substring(0, maxDigits);
        }
        label.setText(onLabel);
    }
@ FXML protected void OnNumberPressed ( ActionEvent e ) { id = updateId ( e ) ; log . info ( "Pressed: {}" , id ) ; onLabel = label . getText ( ) ; if ( status ( onLabel ) == - 1 ) return ; if ( onLabel . equals ( "0" ) ) builder = new StringBuilder ( ) ; switch ( id ) { case "zeroButton" -> { if ( onLabel . startsWith ( "0" ) && ( ! onLabel . contains ( "." ) ) ) { log . error ( "Cannot append 0" ) ; return ; } builder . append ( 0 ) ; } case "oneButton" -> builder . append ( 1 ) ; case "twoButton" -> builder . append ( 2 ) ; case "threeButton" -> builder . append ( 3 ) ; case "fourButton" -> builder . append ( 4 ) ; case "fiveButton" -> builder . append ( 5 ) ; case "sixButton" -> builder . append ( 6 ) ; case "sevenButton" -> builder . append ( 7 ) ; case "eightButton" -> builder . append ( 8 ) ; case "nineButton" -> builder . append ( 9 ) ; case "piButton" -> { builder = new StringBuilder ( ) ; builder . append ( round ( BigDecimal . valueOf ( Math . PI ) ) ) ; } case "eButton" -> { builder = new StringBuilder ( ) ; builder . append ( round ( BigDecimal . valueOf ( Math . E ) ) ) ; } } onLabel = builder . toString ( ) ; if ( hasTooManyDigits ( onLabel . length ( ) ) ) { log . error ( "Maximum limit of digits reached" ) ; onLabel = onLabel . substring ( 0 , maxDigits ) ; } label . setText ( onLabel ) ; }
Appends to the label the number of the corresponding button
 respecting the limit of maximum digits allowed.
Appends to the label the number of the corresponding button respecting the limit of maximum digits allowed .