所以我昨天刚开始自学Java,在我无限的无聊中决定测试我所知道的一点点,并试图制作一个简单的基于文本的游戏。我正在使用扫描仪询问玩家他想成为哪个班级,但是当我运行代码时,我无法输入任何内容。到目前为止,这是我的代码
import java.util.Scanner;
public class mainscript {
public static void main(String args[]){
System.out.println("Welcome to your first quest, young lord.");
System.out.println("In this quest, you will face many foes.");
System.out.println("What type of warrior are you, Sire?");
System.out.println("[use propper caps](Warrior, Rogue, Mage, Brute)");
Scanner c = new Scanner(System.in);
Scanner Warrior = null;
Scanner Rogue = null;
Scanner Mage = null;
if (c == Warrior){//c = class
System.out.println("So you are a warrior.");
System.out.println("You come equipped with the following items.");
System.out.println("Sword(20), Shield(10), Gold(20), and 50 points of health.");
System.out.println("Defeat enemies and do side quests to earn more money for items.");
int Sword, Shield, Health, Money;
Sword = 20;
Shield = 10;
Health = 50;
Money = 20;
}else if(c == Rogue){
System.out.println("So you are a Rogue.");
System.out.println("You are equipped with the following items.");
System.out.println("Dagger(20), Gloves(50), Buckler(10), Gold(20) and 40 points of health");
System.out.println("Defeat enemies and do side quests to earn more money for items.");
System.out.println("Alternately, use your Gloves to steal gold from your enemies in combat.");
int Dagger, Gloves, Buckler, Money, Health;
Dagger = 20;
Gloves = 50;
Buckler = 20;
Money = 20;
Health = 40;
}else if(c == Mage){
System.out.println("So you are a Mage.");
System.out.println("You are equipped with the following items.");
System.out.println("");
System.out.println("Defeat enemies and do side quests to earn more money for items.");
int Knife, Mana, Health;
}
}
}
我只是想知道为什么我在 Eclipse 中运行代码时无法输入任何内容。同样,我对编程非常陌生,所以如果你能相应地回答我可以理解我的错误,我将非常感激。