82
ComPonent-oriented develoPment and assemblY
double tax = 0;
double totalPrice = 0;
List<BillLineItem> billLineItems = new
ArrayList<BillLineItem>();
//Create a bill line item for each order item
//and calculate its price components
for (OrderItem orderItem : order.
getOrderedItems()) {
Food food = orderItem.getFood();
int quantity = orderItem.getQuantity();
BillLineItem billLineItem = new
BillLineItem(food.getName(),
food.getPrice(), food.getTaxRate(),
quantity);
//Calculate price for individual bill line item
double ite mBasePrice =
billLineItem.getUnitPrice()
* billLineItem.getQuantity();
double itemTax = itemBasePrice * billLineItem.
getTaxRate()/100;
double itemPrice = itemBasePrice + itemTax; ...