cartmodel.java

来自「一个优秀的供应商管理系统」· Java 代码 · 共 50 行

JAVA
50
字号
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 + =
减小字号Ctrl + -
显示快捷键?