📄 cartmodel.java
字号:
package apusic.myshop.cart.model;import java.io.Serializable;import java.util.Iterator;import java.util.Collection;import apusic.myshop.util.Debug;public class CartModel { private Collection items; public CartModel(Collection items) { this.items = items; } public int getSize() { if (items != null) return items.size(); else return 0; } /** @return an collection of all the CartItems. */ public Collection getCart() { return items; } /** @return an iterator over all the CartItems. */ public Iterator getItems() { return items.iterator(); } public double getTotalCost() { double total = 0; for (Iterator li = getItems(); li.hasNext(); ) { CartItem item = (CartItem) li.next(); total += item.getTotalCost(); } return total; } /** * copies over the data from the specified shopping cart. Note * that it is a shallow copy. */ public void copy(CartModel src) { this.items = src.items; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -