/** * Takes the barcode for a product and adds it to the checkout * * @param input The barcode for the product as a string * @return True if the product was added, false if it failed */ public static boolean addToCart(String input) { String tempBarCode = "-1"; if (input != null && !input.equals("")) { tempBarCode = input; // disallows the user from entering nothing or clicking cancel. } else if ((input == null) || ("".equals(input))) { return false; } String adding = itemDatabase.getEntryName(tempBarCode).orElse("ERROR"); if (adding != null && !adding.equals("ERROR")) { System.out.println(tempBarCode + "\n" + adding); checkOuts.addProduct(tempBarCode, adding); // otherwise, add the product as normal. return true; } return false; }
public static String getItemName(String barcode) { return itemDatabase.getEntryName(barcode).orElse("ERROR"); }