I am trying to write code for a poker game to delete cards at certain indices using an array.
The code i have so far is the following and is not working.
ncard is the number of cards currently in the hand. any help would be appreciated.
/**
* discard the indexed cards from the Hand.
* @param indices the indices of cards to delete.
* @return true if all Cards deleted, false if not.
*/
public boolean discard(int[] indices){
int i = 0;
while (i < indices.length){
if (indices[i] < 0 || indices[i] >= ncard)
{
return false;
}
for (int in = indices[i]; in < ncard; in++){
cards[in] = null;
ncard--;
}
i++;
}
return true;
}