📄 cart.java
字号:
package cart;
import java.util.Vector;
public class Cart {
Vector v = new Vector();
String act = null;
String item = null;
private void addItem(String id) {
v.addElement(id);
}
private void removeItem(String id) {
v.removeElement(id);
}
public void setItem(String id) {
item = id;
}
public void setAct(String s) {
act = s;
}
public String[] getItems() {
String[] s = new String[v.size()];
v.copyInto(s);
return s;
}
public void processRequest() {
if (act.equals("add"))
addItem(item);
else if (act.equals("remove"))
removeItem(item);
// reset at the end of the request
reset();
}
// reset
private void reset() {
act = null;
item = null;
}
public void clearAll(){
v.removeAllElements();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -