public class Inventory
{
private int size = 10;
private boolean full = false;
private boolean empty = true;
public ArrayList
public Inventory(int s) {size = s;}
public boolean isfull() {space_left(); return full;}
public boolean isEmpty() {space_left(); return empty;}
public int num_held() {return item.size();}
public int max_held() {return size;}
public int space_left()
{
int room = size - item.size();
if(room==0){full = true;}else if(room==size){empty = true;}
return room;
}
public boolean add_item(Item a)
{
if(full){return false;}
//else if(item.size()==size){return false;}
else
{
item.add(a);
space_left();
return true;
}
}
public boolean remove_item(Item a)
{
if(item.size()==0){return false;}
item.remove(a);
space_left();
return true;
}
}
No comments:
Post a Comment