| 构造器和说明 |
|---|
Bag() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addItem(AbstractItem item)
添加一个物品
|
void |
addItem(int gridId,
AbstractItem item)
添加一个物品
|
void |
addItems(List<AbstractItem> items)
添加一串物品
|
protected abstract Map<Integer,AbstractItem> |
bag() |
void |
canAddItem(AbstractItem item)
是否能添加物品
|
void |
canAddItems(List<AbstractItem> items)
能否批量添加物品
|
abstract int |
capacity()
容量
|
int |
getAnEmptyGrid()
获取一个空的格子
|
AbstractItem |
getItem(int gridId)
获取相应格子的物品
|
int |
getItemCount(Test1<AbstractItem> filter)
获取符合条件的物品的数量
|
List<AbstractItem> |
getItems(Test1<AbstractItem> filter)
获取符合条件的物品
|
void |
makeUp()
整理
|
void |
merge(int gridOne,
int gridAnother)
合并物品
|
protected abstract void |
onItemAdded(int gridId,
AbstractItem item)
添加物品后
|
abstract void |
onItemChanged(AbstractItem item)
物品信息产生变化
|
protected abstract void |
onItemRemoved(int gridId,
AbstractItem item)
删除物品后
|
int |
remain()
剩余空间
|
AbstractItem |
removeItem(int gridId)
删除某物品
|
List<AbstractItem> |
removeItems(Test1<AbstractItem> filter)
根据条件删除相关物品
|
int |
size()
内容大小
|
void |
split(int gridId,
int num)
拆分物品
|
public void canAddItem(AbstractItem item) throws ItemZeroNumException, BagFullException, ItemNotExistException
item - ItemZeroNumExceptionBagFullExceptionItemNotExistExceptionpublic void canAddItems(List<AbstractItem> items) throws ItemZeroNumException, BagFullException, ItemNotExistException
items - ItemZeroNumExceptionBagFullExceptionItemNotExistExceptionpublic void addItem(int gridId,
AbstractItem item)
throws BagFullException,
BagGridOcuppiedException,
ItemZeroNumException,
ItemNotExistException
gridId - item - BagFullExceptionBagGridOcuppiedExceptionItemZeroNumExceptionItemNotExistExceptionpublic void addItem(AbstractItem item) throws BagFullException, BagGridOcuppiedException, ItemZeroNumException, ItemNotExistException
public void addItems(List<AbstractItem> items) throws BagFullException, BagGridOcuppiedException, ItemNotExistException, ItemZeroNumException
public AbstractItem removeItem(int gridId)
gridId - public List<AbstractItem> removeItems(Test1<AbstractItem> filter)
filter - public AbstractItem getItem(int gridId)
gridId - public List<AbstractItem> getItems(Test1<AbstractItem> filter)
filter - public int getItemCount(Test1<AbstractItem> filter)
filter - public void makeUp()
public void split(int gridId,
int num)
throws ItemNotExistException,
ItemSliptNotEnoughNumException,
BagFullException,
BagGridOcuppiedException,
ItemZeroNumException
public void merge(int gridOne,
int gridAnother)
throws ItemNotExistException,
ItemNotSameTypeException,
ItemOverStackException,
ItemZeroNumException
gridOne - gridAnother - ItemNotExistExceptionItemZeroNumExceptionItemOverStackExceptionItemNotSameTypeExceptionpublic int getAnEmptyGrid()
public int size()
public int remain()
protected abstract Map<Integer,AbstractItem> bag()
public abstract int capacity()
protected abstract void onItemAdded(int gridId,
AbstractItem item)
gridId - item - protected abstract void onItemRemoved(int gridId,
AbstractItem item)
gridId - item - public abstract void onItemChanged(AbstractItem item)
item - Copyright © 2017. All rights reserved.