Advertisement
JeffGrigg

Process Bar Code separate from Display Message

Dec 22nd, 2023
2,041
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.60 KB | Software | 0 0
  1.     public void onBarcode(final String barcode) {
  2.         final var message = processBarcode(barcode);
  3.         display.displayMessage(message);
  4.     }
  5.  
  6.     private String processBarcode(final String barcode) {
  7.         if (barcode.isEmpty()) {
  8.             return display.getDisplayEmptyBarcodeMessage();
  9.         } else {
  10.  
  11.             final Price price = catalog.findPrice(barcode);
  12.  
  13.             if (price == null) {
  14.                 return display.getDisplayProductNotFoundMessage(barcode);
  15.             } else {
  16.                 return display.getDisplayPriceMessage(price);
  17.             }
  18.         }
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement