예제 #1
0
  public static boolean getProduct(String code) {
    boolean isFound = false;

    Product tempProduct = new Product();

    tempProduct = ProductDB.getProduct(code);
    if (tempProduct.getCode() != null) isFound = true;

    return isFound;
  }
예제 #2
0
파일: Cart.java 프로젝트: Wrrzag/Junit-test
  /**
   * Adds the specified quantity of the product with the specified code to the cart.
   *
   * @param upc the code of the product to add.
   * @param quantity the quantity to add.
   * @throws BadUPCException if the code doesn't belong to any product.
   * @throws BadQuantityException if the quantity is less than 0.
   */
  public void addItem(UPC upc, int quantity) throws BadUPCException, BadQuantityException {
    if (quantity < 0) {
      throw new BadQuantityException();
    }

    if (quantity > 0) {
      cart.addMoney(
          new Money(
              db.getPrice(upc).getPrice().multiply(new BigDecimal(quantity)),
              db.getPrice(upc).getCurrency()));
    }
  }
예제 #3
0
 public boolean isExist(String code) {
   return productDB.isItemExist(code);
 }