?? goods.java
字號(hào):
package com.chapter2;
import java.util.*;
import java.io.*;
public class Goods implements Serializable
{
public Hashtable Goods=new Hashtable();
//構(gòu)造函數(shù)
public void Goods()
{ }
//將某個(gè)商品信息加入購(gòu)物車(chē)
public void add(String GoodsName,int GoodsNumber)
{
if(Goods.containsKey(GoodsName))
{//購(gòu)物車(chē)中存在此商品
int iTemp=((Integer)Goods.get(GoodsName)).intValue();
iTemp=iTemp+GoodsNumber;
Goods.put(GoodsName,new Integer(iTemp));
}
else
{//購(gòu)物車(chē)中不存在此商品
Goods.put(GoodsName,new Integer(GoodsNumber));
}
}
//獲取購(gòu)物車(chē)中所有商品信息
public Hashtable show()
{
return Goods;
}
//從購(gòu)物車(chē)中刪除一件商品信息
public void delete(String GoodsName)
{
Goods.remove(GoodsName);
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -