📄 40c4b67598f4001b1767ee232a2585d9
字号:
package bean;
import java.util.HashMap;
public class Car {
private String userId;//用户的标识
private HashMap items;//购物车中的物品
public Car(){items=new HashMap(); }
public void addItem(String id,int quantity)
{ items.put(id,new Integer(quantity)); }
public void removeItem(String id)
{ items.remove(id); }
public void updateItem(String id,int quantity)
{
if(items.containsKey(id))items.remove(id);
items.put(id,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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -