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 getPrice(FoodItem item); public double tax(double price);//10% tax}
package com.lec.test;public class FoodItem { private String menuId; private String name; private int quantity; public FoodItem(String menuId, String name, int quantity){ this.menuId = menuId; this.name = name; this.quantity = quantity;} public String getMenuId(){ return menuId;} public void setMenuId(String menuId){ this.menuId = menuId;} public String getName(){ return name;} public void setName(String name){ this.name = name;} public int getQuantity(){ return quantity;} public void setQuantity(int 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 setOrder(Order order){ this.order = order;} public List getItems(){ return items;} public void setItems(List items){ this.items = items;} public double getTotalPrice(){ double totalAmount =0.0; for(FoodItem item:items){ System.out.println(item.getName()+""+ item.getQuantity()); totalAmount += order.getPrice(item)* item.getQuantity();} totalAmount = totalAmount + order.tax(totalAmount); return totalAmount;}}1.The code above implement a McDonald's 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)
2.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)
3.Test the getTotalPrice method using Mockito

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!