-
Array
Code:
public boolean takeOut(CD aCD, Person aPerson)
{
int out;
if((out = discsArray.indexOf(aCD)) != 0)
{
CD cd = (CD)discsArray.get(out);
if(cd.person == null)
{
cd.person = aPerson;
discsArray.set(out, cd);
return true;
}
}
i use this code to remove an item from the array, how would i implement this on the gui so that when i enter a persons name and the item they want to take out in textfields and press the button it should check the array to see if the item is there then remove the item from the list?
Code:
if(e.getSource() == takeOut)
{
if(takingOutCD.getText().equals(""))
{
display.setText("Please Enter Person Taking Out CD");
} //End if
else if(cdBeingTakenOut.getText().equals(""))
{
display.setText("Please Enter Title Of CD Being Taken Out");
} //End else if
else
{
display.setText("CD Taken Out By: " + p1);
}
}
-
Re: Array
Have you considered using other data structures, e.g. ones that provide key based retrieval and deletion?