Ejemplo n.º 1
0
 /** Checkout processes grocery store items from customer's basket for a given date. */
 public static void tc00001(ArrayList<Basket> list) {
   System.out.println("GP1-00001");
   Basket b;
   Receipt receipt = null;
   Tax tax = new Tax(7.7, new Date(), new Date());
   for (int i = 0; i < 3; i++) {
     // System.out.println(list.get(i));
     b = list.get(i);
     try {
       if (b.getPaymentType().equals("card")) {
         receipt =
             new Receipt(
                 b.getDate(),
                 b.getItemBasket(),
                 b.getCustomer(),
                 tax,
                 b.getCashback(),
                 b.getCouponList());
       } else if (b.getPaymentType().equals("cash")) {
         receipt =
             new Receipt(
                 b.getDate(), b.getItemBasket(), b.getAmountPaid(), tax, b.getCouponList());
       }
     } catch (NullPointerException e) {
       System.out.println("Empty");
     }
     System.out.println("[TESTING REQ GP1-00001]");
     System.out.println(receipt.makeHeader());
     System.out.println(receipt.printGroceries());
     System.out.println("[END TESTING REQ GP1-00001]");
   }
 }
Ejemplo n.º 2
0
 /** Checkout calculates and print sales tax for any taxable item in a given customer's basket. */
 public static void tc00016() {
   System.out.println("GP1-00016 calc and pritn sales tax");
   Basket b;
   Receipt receipt = null;
   Tax tax = new Tax(7.7, new Date(), new Date());
   int loc = 30;
   for (int i = loc; i <= loc + 5; i++) {
     // System.out.println(list.get(i));
     b = list.get(i);
     try {
       if (b.getPaymentType().equals("card")) {
         receipt =
             new Receipt(
                 b.getDate(),
                 b.getItemBasket(),
                 b.getCustomer(),
                 tax,
                 b.getCashback(),
                 b.getCouponList());
       } else if (b.getPaymentType().equals("cash")) {
         receipt =
             new Receipt(
                 b.getDate(), b.getItemBasket(), b.getAmountPaid(), tax, b.getCouponList());
       }
     } catch (NullPointerException e) {
       System.out.println("Empty");
     }
     System.out.println("[TESTING REQ GP1-00016]");
     System.out.print(receipt.printGroceries());
     System.out.print(receipt.printTotal());
     System.out.println("[END TESTING REQ GP1-00016]\n");
   }
 }
Ejemplo n.º 3
0
 /** Checkout calculates and print the price for any item that is purchased by quantity. */
 public static void tc00018() {
   System.out.println("GP1-00018 purchased by quantity");
   Basket b;
   Receipt receipt = null;
   Tax tax = new Tax(7.7, new Date(), new Date());
   int loc = 40;
   for (int i = loc; i <= loc + 3; i++) {
     // System.out.println(list.get(i));
     b = list.get(i);
     try {
       if (b.getPaymentType().equals("card")) {
         receipt =
             new Receipt(
                 b.getDate(),
                 b.getItemBasket(),
                 b.getCustomer(),
                 tax,
                 b.getCashback(),
                 b.getCouponList());
       } else if (b.getPaymentType().equals("cash")) {
         receipt =
             new Receipt(
                 b.getDate(), b.getItemBasket(), b.getAmountPaid(), tax, b.getCouponList());
       }
     } catch (NullPointerException e) {
       System.out.println("Empty");
     }
     System.out.println("[TESTING REQ GP1-00018]");
     System.out.println(receipt.printGroceries());
     System.out.println("[END TESTING REQ GP1-00018]");
     // seems to work for F type groceries...
   }
 }
Ejemplo n.º 4
0
 /**
  * Checkout prints the name of each item purchased left-justified starting in column five of the
  * main item purchase line.
  */
 public static void tc00012() {
   System.out.println("GP1-00012 print name of each item");
   Basket b;
   Receipt receipt = null;
   Tax tax = new Tax(7.7, new Date(), new Date());
   int loc = 34;
   for (int i = loc; i <= loc + 3; i++) {
     // System.out.println(list.get(i));
     b = list.get(i);
     try {
       if (b.getPaymentType().equals("card")) {
         receipt =
             new Receipt(
                 b.getDate(),
                 b.getItemBasket(),
                 b.getCustomer(),
                 tax,
                 b.getCashback(),
                 b.getCouponList());
       } else if (b.getPaymentType().equals("cash")) {
         receipt =
             new Receipt(
                 b.getDate(), b.getItemBasket(), b.getAmountPaid(), tax, b.getCouponList());
       }
     } catch (NullPointerException e) {
       System.out.println("Empty");
     }
     System.out.println("[TESTING REQ GP1-00011]");
     System.out.println("|    X    "); // X in column 5
     System.out.print(receipt.printGroceries());
     System.out.println("|    X   <-- x in column 5 "); // X in column 5
     System.out.println("[END TESTING REQ GP1-00011]\n");
   }
 }
Ejemplo n.º 5
0
 /**
  * Checkout prints the item category code of each item purchased in column thirty-one of the main
  * item purchase line.
  */
 public static void tc00014() {
   System.out.println("GP1-00014 item category code in column 31");
   String test = "|";
   test += StringUtils.repeat(" ", 30);
   System.out.println(test.length());
   test += "X"; // in column 31
   Basket b;
   Receipt receipt = null;
   Tax tax = new Tax(7.7, new Date(), new Date());
   int loc = 34;
   for (int i = loc; i <= loc + 3; i++) {
     // System.out.println(list.get(i));
     b = list.get(i);
     try {
       if (b.getPaymentType().equals("card")) {
         receipt =
             new Receipt(
                 b.getDate(),
                 b.getItemBasket(),
                 b.getCustomer(),
                 tax,
                 b.getCashback(),
                 b.getCouponList());
       } else if (b.getPaymentType().equals("cash")) {
         receipt =
             new Receipt(
                 b.getDate(), b.getItemBasket(), b.getAmountPaid(), tax, b.getCouponList());
       }
     } catch (NullPointerException e) {
       System.out.println("Empty");
     }
     System.out.println("[TESTING REQ GP1-00014]");
     System.out.println(test);
     System.out.print(receipt.printGroceries());
     System.out.println("[END TESTING REQ GP1-00014]\n");
   }
 }
Ejemplo n.º 6
0
 /** GP1-000010 Checkout shall print a blank line after the fifth line on each receipt. */
 public static void tc00010(Receipt receipt) {
   System.out.println("GP1-00010");
   System.out.println("Blank line after the fifth line");
   System.out.println(receipt.makeHeader() + "\n");
 }
Ejemplo n.º 7
0
 /**
  * GP1-00009 Checkout shall print centered on the fifth line from the top of each receipt the
  * store identifier.
  */
 public static void tc00009(Receipt receipt) {
   System.out.println("GP1-00009");
   System.out.println("5th line: store identifier");
   System.out.println(receipt.makeHeader() + "\n");
 }
Ejemplo n.º 8
0
 /**
  * GP1-00008 Checkout shall print centered on the fourth line from the top of each receipt
  * "Hoggley-Woggley-Inc.
  */
 public static void tc00008(Receipt receipt) {
   System.out.println("GP1-00008");
   System.out.println("4th line: Hoggley-Woggley-Inc. centered");
   System.out.println(receipt.makeHeader() + "\n");
 }
Ejemplo n.º 9
0
 /** GP1-00007 Checkout shall print out each receipt with bottom margin of one blank line. */
 public static void tc00007(Receipt receipt) {
   System.out.println("GP1-00007");
   System.out.println("Bottom margin of 1 blank line");
   System.out.println(receipt.makeFooter() + "\n");
 }
Ejemplo n.º 10
0
 /** GP1-00006 Checkout shall print out each receipt with a top margin of three blank lines. */
 public static void tc00006(Receipt receipt) {
   System.out.println("GP1-00006");
   System.out.println("Top margin of 3 blank lines");
   System.out.println(receipt.makeHeader() + "\n");
 }