所以,我正在创建一个基本的“拱廊”项目。我有传递到游戏中的卡片(方法)。我在 Card 类中创建了一个方法,以便能够选择用于游戏的卡片。
public Card choosecard(Card firstCard, Card secondCard) {
Scanner input = new Scanner(System.in);
Card chosen = new Card();
boolean check = false;
while(check == false) {
System.out.println("What card would you like to use?\n 1. " + firstCard.name + "\n 2. " + secondCard.name);
int answer = Integer.parseInt(input.nextLine());
if(answer == 1) {
chosen = firstCard;
check = true;
}
else if(answer == 2) {
chosen = secondCard;
check = true;
}
else {
}
} //while
return chosen;
创建此方法后,我尝试在此上下文中调用它:
public static void terminal(Card card1, Card card2) {
boolean loop = true;
while(loop == true) {
System.out.println("What would you like to do?\n1. Guess Game\n2. Transfer\n3. Prizes\n4. Cancel");
Scanner take = new Scanner(System.in);
int answer = Integer.parseInt(take.nextLine());
switch(answer) {
case 1:
Game.GuessGame(Card.chooseCard(card1, card2));
}
}
我认为这可能是因为我试图在另一个方法的参数中调用一个方法。所以我尝试从其他类调用它,但它仍然给出了找不到符号的错误。
白板的微信
潇潇雨雨
相关分类