I'm writing a video poker in java, and I need to ask the player if the want to remove any cards from their hand. I wrote a while loop for that, but it is not working the way it's supposed to right now. I'd appreciate if someone could send me in the right direction--I'm still new to java.. Thanks. (the counter is there so that the player doesn't remove more than 5 cards)
String response = "y";
int counter = 0;
System.out.println("Remove any cards?");
System.out.println("Enter y for 'yes' and n for 'no'");
response = input.nextLine();
while((response != "n") && (counter < 5))
{
System.out.println("Enter the number of a card to be removed (1-5)");
int l = input.nextInt();
p.removeCard(p.getHand().get(l-1));
p.addCard(cards.deal());
cards.incrementTop();
counter ++;
System.out.println("Card removed. More? Type 'yes' or 'no'");
String answer = input.nextLine();
if (answer == "no")
{
response = "n";
}
}