I have two ArrayLists, a hand of Cards and then a "run" of Cards (Cards are objects.) I am trying to initiate through the "run" of Cards, and remove those specific cards from the Hand.
I have the exact same code in a different method and it works fantastic. For some reason, the code below isn't removing any of the "run" cards from Hand, and I can't figure out why. The debugger shows the method passing the right Card; any ideas?
private ArrayList<ArrayList<Card>> meldDesktop;
public void addMeldRun(ArrayList runToAdd, Hand playerHand, Player player){
this.meldDesktop.add(runToAdd);
//after adding the run to the meld desktop, remove them from the player's
//hand and get points
Iterator<Card> testRoll = runToAdd.iterator();
while (testRoll.hasNext()){
int points = 0;
Card removeCard = testRoll.next();
playerHand.removeCard(removeCard);
points = removeCard.pointValue() + points;
player.setScore(points);
}
}
public ArrayList removeCard (Card newCard){
handCard.remove(newCard);
//Collections.sort(handCard);
return handCard;
}
Aucun commentaire:
Enregistrer un commentaire