java通过在用户每次输入相应值时添加一张卡来创建一副卡
我试图通过用户输入制作一副卡片。例如,如果用户输入0,4,则显示的卡将存储为红心4。到目前为止,我的代码根本不适用于西服。我计划做同样的事情,如果其他卡的价值以及。我在卡片下面有错误。nextLine()、int卡[]和字符串套装。有人知道更简单的方法吗
public void addCard() {
String suit[] = {"Hearts", "Diamonds", "Spades", "Clubs"};
String value[] = {"ZZZZ", "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"};
System.out.println("Please enter a suit");
Scanner input = new Scanner(System.in);
int card[] = card.nextLine();
int i;
if(int card[] = 0){
String newSuit [] = String suit[0];
}
else if(int card[] = 1){
String newSuit [] = String suit[1];
}
else if (int card[] = 2){
String newSuit [] = String suit [2];
}
else if (int card[] = 3){
String newSuit [] = String suit [3];
}
}
# 1 楼答案
也许你想要这样的东西