40eea3f2e6ee001b178095bc6b40daf6

来自「Internet 开发技术分章节代码和自己完成的课程设计全代码(在zuoye文件」· 代码 · 共 47 行

TXT
47
字号
package bean;
import java.util.HashMap;

	public class Cart 
	{
		private String userId;//用户的标识
		private HashMap items;//购物车中的物品
		public Cart()
		{
			items=new HashMap();
		}
		public void addItem(String itemId,int quantity)
		{
			items.put(itemId,new Integer(quantity));
		}
		public void removeItem(String itemId)
		{
			items.remove(itemId);
		}
		public void updateItem(String itemId,int quantity)
		{
			if(items.containsKey(itemId))items.remove(itemId);
			items.put(itemId,new Integer(quantity));
		}
		public HashMap getItems()
		{
			return this.items;
		}
		public void setUserId(String userId)
		{
			this.userId=userId;
		}
		public String getUserId()
		{
			return this.userId;
		}
		public void clear()
		{
			items.clear();
		}
	}

			
		

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?