package mygame;
public class Inventar {
public String[] places;
public int big;
public String[] src;
public Inventar()
{
}
public void setPlaces(int i)
{
places = new String[i+1];
src= new String[i+1];
big=i;
}
public int newItem(String name)
{
for(int s=0 ; s<=big;s++)
{
if (places[s]==null)
{
places[s]=name;
return (s);
}
}
return (-1);
}
public void addSrc(int id,String path)
{
src[id]=path;
}
public void removeItem(int id)
{
places[id]=null;
src[id]=null;
}
public String getItemId(int id)
{
return (places[id]);
}
public String getItemSrc(int id)
{
return (src[id]);
}
public int searchItemId(String name)
{
for(int s=0 ; s<=big;s++)
{
if (places[s].equals(name))
{
return (s);
}
}
return -1;
}
public int searchItemSrc(String path)
{
for(int s=0 ; s<=big;s++)
{
if (src[s].equals(path))
{
return (s);
}
}
return -1;
}
public String printItems()
{
String ret=places[0];
for(int s=0 ; s<=big;s++)
{
ret = ret + ","+places[s];
}
return ret;
}
public void ItemMove(int id,int id2)
{
String name=places[id];
String name2=places[id2];
String path=src[id];
String path2=src[id2];
if (name2==null)
{
places[id2]=name;
src[id2]=path;
removeItem(id);
}
else
{
places[id2]=name;
src[id2]=path;
removeItem(id);
newItem(name2);
addSrc(id2,path2);
}
}
}