public static void main(String[] args) { Items i1 = new Items(1,"高数","广州",80,500,"001.jpg"); Items i2 = new Items(2,"软件工程","上海",120,800,"002.jpg"); Items i3 = new Items(2,"软件工程","上海",120,800,"002.jpg"); Cart c = new Cart(); c.addGoodsInCart(i1, 1); c.addGoodsInCart(i2, 2); c.addGoodsInCart(i3, 3); System.out.println("购物车的总金额为:"+c.getTotalPrice()); Set<Map.Entry<Items, Integer>> items= c.getGoods().entrySet(); for(Map.Entry<Items, Integer> obj:items) { System.out.println(obj); } System.out.println("购物车的总金额为"+c.getTotalPrice()); }
|