Package com.ap.givemetheprice.exercise

Source Code of com.ap.givemetheprice.exercise.Exercise

package com.ap.givemetheprice.exercise;

import java.math.BigDecimal;

import com.ap.givemetheprice.bean.basket.Basket;
import com.ap.givemetheprice.bean.factory.ItemFactory;
import com.ap.givemetheprice.bean.item.ItemType;


/**
* Run it to see the output as requested in the exercise.
*
* @author AP
*
*/
public class Exercise {

  public static void main(String[] args) {
   
    Basket basket = new Basket();
    basket.setBasketName("Basket One");
    basket.getItems().add(ItemFactory.getItem(ItemType.BOOKS, "book", 1, false, new BigDecimal("12.49")));
    basket.getItems().add(ItemFactory.getItem(ItemType.OTHERS, "music CD", 1, false, new BigDecimal("14.99")));
    basket.getItems().add(ItemFactory.getItem(ItemType.FOOD, "chocolate bar", 1, false, new BigDecimal("0.85")));
    System.out.println(basket.printReceipt());
   
    basket = new Basket();
    basket.setBasketName("Basket Two");
    basket.getItems().add(ItemFactory.getItem(ItemType.FOOD, "imported box of chocolates", 1, true, new BigDecimal("10.00")));
    basket.getItems().add(ItemFactory.getItem(ItemType.OTHERS, "imported bottle of perfume", 1, true, new BigDecimal("47.50")));
    System.out.println(basket.printReceipt());
   
    basket = new Basket();
    basket.setBasketName("Basket Three");
    basket.getItems().add(ItemFactory.getItem(ItemType.OTHERS, "imported bottle of perfume", 1, true, new BigDecimal("27.99")));
    basket.getItems().add(ItemFactory.getItem(ItemType.OTHERS, "bottle of perfume", 1, false, new BigDecimal("18.99")));
    basket.getItems().add(ItemFactory.getItem(ItemType.MEDICAL, "packet of headache pills", 1, false, new BigDecimal("9.75")));
    basket.getItems().add(ItemFactory.getItem(ItemType.FOOD, "box of imported chocolates", 1, true, new BigDecimal("11.25")));
    System.out.println(basket.printReceipt());

  }

}
TOP

Related Classes of com.ap.givemetheprice.exercise.Exercise

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.