What is the correct code for me to discard the item one, then put item two in item one's place, item three in item two's place, item four in item three's place, and for item five, it will be the new equipped item.
it should also return the discarded item at the end. Thanks
PHP Code:
public void equip (Item e)
{
if (itemOne == null)
{
itemOne = e;
itemCounter+= 1;
}
else if (itemTwo == null)
{
itemTwo = e;
itemCounter+= 1;
}
else if (itemThree == null)
{
itemThree = e;
itemCounter+= 1;
}
else if (itemFour == null)
{
itemFour= e;
itemCounter+= 1;
}
else if (itemFive == null)
{
itemFive = e;
itemCounter+= 1;
}
}
/**
* The swap() method enables the Avatar to discard the Item in the first position of his/her belt,
* advance the remaining Items in his/her belt one position forward, then place a new Item
* in the last position of his/her belt.
*
* @param e - : the Item to be added to the Avatar's belt
* @param return the name of the Item discarded from the Avatar's belt
*/
public String swap (Item e)
{
?????
}