由于这个错误,我很难完成这个冒险故事



我是一个非常早期的初学者,我有一个项目即将到期,创建一个选择你自己的冒险故事。我还没有完成,但我得到了错误"Main.java not found"任何帮助吗?谢谢!

import java.util.Scanner;

class ChoicesStory {
public static void main(String[] args) {
new ChoicesStory();
}

Scanner stringReader = new Scanner(System.in);
Scanner numberReader = new Scanner(System.in);
public ChoicesStory() {
System.out.println("You're lost in a dark forest.");
System.out.println("You see a faint light in the distance resembling a fire.");
System.out.println("Do you want to go towards the light or keep walking?");
System.out.print("Enter 'light' or 'walk' ");
String choice = stringReader.nextLine();
if (choice.equals("light")) {
lightStory();
}
if (choice.equals("walk")) {
walkStory();
}
}
public void lightStory() {
System.out.println("You walk towards the fire and see an old man sitting on a log.");
System.out.println("You ask him if he knows how to get back to your town.");
System.out.println("You see the man pull out a knife and look at you menacingly.");
}
public void walkStory() {
}
}

您可以将文件命名为Main.java,但在文件中,类名称为ChoicesStory。这两个应该是一样的。如果您使用的是IDE(例如:eclipse),那么它应该已经显示了一个错误。看起来你已经使用java Main

在命令行中运行了程序

最新更新