Suppose I have a class. It is called Item.
public class Item {
public boolean usable = false;
protected boolean usage;
public int id;
public String name;
public String type;
public int stacknum;
protected int tier;
public String rarity;
boolean equipable;
boolean equiped;
String altName;
public Item(int idIn, String nameIn, String typeIn) {
usage = false;
id = idIn;
name = nameIn;
type = typeIn;
stacknum = 0;
tier = 0;
rarity = "Common";
}//end of constructor
}//end of class
Lets say I have an array called:
Inventory = new Item[5];
It contains these elements:
Item elementOne = new Item(1, "Element One", "Array Element");
Item elementTwo = new Item(2, "Element Two", "Array Element");
etc.
Inventory[0] = elementOne;
Inventory[1] = elementTwo;
Inventory[2] = elementThree;
and so forth. How would I go about writing a method to find out which element in array an Item(or anything in general) is I.e.
elementOne.findPlace
would return the int value of 0.
thanks!