package ustc.maomao.patterns.cor;

import ustc.maomao.patterns.support.MealOrder;
import ustc.maomao.patterns.visitor.FoodLevelVisitor;
import ustc.maomao.patterns.visitor.FoodTypeVisitor;

/**
 * @author Keene. Mail: waterzhj@ustc.edu.cn
 * 
 *         该代码遵循MIT License, 详细见 https://mit-license.org/
 * 
 *         Copyright {2017} {Keene}
 * 
 *         designed by Keene, implemented by {Keene}
 * 
 *         订单控制器
 * 
 */
public class MealOrderController {

	private OrderValidator validator;

	/**
	 * 验证目标订单是否有效
	 * 
	 * @param order
	 *            目标订单
	 * @return 验证结果
	 */
	public boolean validateOrder(MealOrder order) {        
		return validator.valid(order);
	}

	/**
	 * @param validator
	 *            the validator to set
	 */
	public void setValidator(OrderValidator validator) {
		this.validator = validator;
	}
	
	/**
	 * 显示订单菜品统计信息
	 */
	public void dispayOrderStatis(MealOrder order) {
		FoodTypeVisitor visitor = new FoodTypeVisitor();
		order.accept(visitor);
		visitor.displayResult();
	}

	/**
	 * 检查订单并提醒客户关于菜品的信息
	 */
	public void warningOrder(MealOrder order) {
		FoodLevelVisitor visitor = new FoodLevelVisitor();
		order.accept(visitor);
	}	
	
}

@@ -114,29 +114,28 @@
 visitor.Food
-Level
+Type
 Visitor;%0D%0Aim
@@ -164,32 +164,33 @@
 rns.visitor.
-FoodType
+MealOrder
 Visitor;%0D%0A%0D%0A
@@ -511,16 +511,19 @@
 idator;%0D
+%0A%09%0D
 %0A%0D%0A%09/**%0D
@@ -948,63 +948,38 @@
 rder
-) %7B%0D%0A%09%09FoodTypeVisitor visitor = new FoodTypeVisitor();
+,MealOrderVisitor visitor) %7B%09%09
 %0D%0A%09%09
@@ -1004,23 +1004,42 @@
 or);%0D%0A%09%09
+((FoodTypeVisitor)
 visitor
+)
 .display
@@ -1134,65 +1134,38 @@
 rder
-) %7B%0D%0A%09%09FoodLevelVisitor visitor = new FoodLevelVisitor();
+,MealOrderVisitor visitor) %7B%09%09
 %0D%0A%09%09

modify visitor pattern