【发布时间】:2013-11-24 12:19:31
【问题描述】:
我正在尝试通过用户输入制作一副纸牌。例如。如果用户输入 0,4,则显示的卡片将存储为红桃 4。到目前为止,我的代码根本不适用于西装。如果卡的值也一样,我也打算这样做。
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];
}
}
【问题讨论】:
-
请更具描述性 - 什么不完全有效? (除了你的代码不会像当前编写的那样编译......)
-
完全不清楚,到底发生了什么以及您的期望是什么。
-
它肯定会给你一个编译器错误,你根本没有提到。为什么?
-
每次用户输入值时添加一张卡片来创建一副卡片
标签: java