我对 Java 编程非常陌生,我正在尝试制作一个 Poker Hand Evaluator。我正在使用 for 循环询问卡片的花色和价值。出于某种原因,它在 for 循环的第一次迭代中起作用,但之后只要求我输入一个值。这是我的代码:
import java.util.Scanner;
public class PokerRun {
public static void main(String[] args) {
int [] suit = new int[5];
int [] value = new int[20];
Card card1 = new Card();
Scanner in = new Scanner(System.in);
int counter = 1;
System.out.println("Welcome to the Poker Hand Evaluator!");
for(int i = 1; i<6; i++)
{
System.out.println("What is the suit of card " + i + "?\nPlease type the suit in all lowercase letters: ");
card1.suit = in.nextLine();
System.out.println("What is the value of card " + i + "? (J = 11, Q = 12 K = 13, A = 14");
card1.value = in.nextInt();
//checks if face card, if true, then changes card.facecard
if(card1.value == 11)
card1.facecard = "Jack";
else if(card1.value == 12)
card1.facecard = "Queen";
else if(card1.value == 13)
card1.facecard = "King";
else if(card1.value == 12)
card1.facecard = "Ace";
if(card1.value<11)
System.out.println("You entered a " + card1.value + " of " + card1.suit + ".");
else
System.out.println("You entered a " + card1.facecard + " of " + card1.suit + ".");
}
}
}