?? allmerchandise.java
字號:
package RegisterAndLogin;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Collection;
import java.io.Serializable;
class AllMerchandise implements Serializable
{
String ShopId="";
String ShopName="";
HashMap<Integer,merchandise> items=null;
int numofItems=0;
public AllMerchandise()
{
items=new HashMap<Integer,merchandise>();
}
public String GetShopId()
{
return ShopId;
}
public void SetShopId(String ShopId)
{
this.ShopId=ShopId;
}
public void SetShopName(String ShopName)
{
this.ShopName=ShopName;
}
public String GetShopName()
{
return ShopName;
}
public merchandise getoneItem (Integer goodsId)
{
if(items.containsKey(goodsId))
return (merchandise)items.get((Integer)goodsId);
else
return null;
}
//增加一個條目
public synchronized void addItem(Integer goodsId,merchandise goods)
{
if(!items.containsKey(goodsId))
{
items.put(goodsId,goods);
numofItems++;
}
}
//刪除一個條目
public synchronized void deleteItem(Integer goodsId)
{
if(items.containsKey(goodsId))
{
items.remove(goodsId);
numofItems--;
}
}
//修改一個商品的信息
public synchronized void modify(merchandise goods)
{
int goodsid=goods.getgoodsId();
items.remove(goodsid);
items.put(goodsid, goods);
}
//清除所有商品
public synchronized void clear()
{
items.clear();
numofItems=0;
}
//某個商品id是否可用
public synchronized Boolean isusable(int goodsid)
{
if(items.containsKey(goodsid))
return false;
else
return true;
}
//商店中商品的數量
public int getNumofItems()
{
return numofItems;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -