Question: package com.lec.test; public interface Order { public double getPrice ( FoodItem item ) ; public double tax ( double price ) ; / / 1
package com.lec.test;public interface Order public double getPriceFoodItem item; public double taxdouble price; tax
package com.lec.test;public class FoodItem private String menuId; private String name; private int quantity; public FoodItemString menuId, String name, int quantity this.menuId menuId; this.name name; this.quantity quantity; public String getMenuId return menuId; public void setMenuIdString menuId this.menuId menuId; public String getName return name; public void setNameString name this.name name; public int getQuantity return quantity; public void setQuantityint quantity this.quantity quantity;
package com.lec.test;import java.util.List;public class OrderCart private Order order; private List items; public Order getOrder return order; public void setOrderOrder order this.order order; public List getItems return items; public void setItemsList items this.items items; public double getTotalPrice double totalAmount ; forFoodItem item:items System.out.printlnitemgetName item.getQuantity; totalAmount order.getPriceitem item.getQuantity; totalAmount totalAmount order.taxtotalAmount; return totalAmount;The code above implement a McDonalds Ordering System Each branch can create its own menu but unfortunately, the price is determined by the head office. FoodItem class is designed to create a menu but you should use Order interface to get the price of each menu. Also you can ask amount of tax using the same interface
Implementing the Order Interface is not your task. Your task is to test the getTotalPrice method. Keep in mind, to test getTotalPrice you should ask a price to head office using the Order interface
Test the getTotalPrice method using Mockito
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
