package com.ice.creation.Builder;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ice
 * @blog https://blog.csdn.net/dreaming_coder
 * @description
 * @create 2021-10-15 21:24:09
 */
public class Meal {

    private final List<Item> items = new ArrayList<>();

    public void addItem(Item item) {
        items.add(item);
    }

    //获取总消费
    public float getCost() {
        float cost = 0.0f;

        for (Item item : items) {
            cost += item.getPrice();
        }

        return cost;
    }

    public void showItem() {
        for (Item item : items) {
            System.out.print("餐品：" + item.getName());
            System.out.print("，包装：" + item.packing().getPack());
            System.out.println("，价格：￥" + item.getPrice());
        }
    }

}
