在Java中,是否可以不使用关键字“quot”来实现接口及其方法;实施;?
我有家庭作业要做(实际上是我的女朋友:-D),我能做什么和不能做什么都有一些限制。 在我的NetBeans项目文件夹中,有两个名为“接口”和“家庭作业”的文件夹。 文件夹“interfaces”包含不允许编辑的接口和类,因为xD对我们这样说。 我只允许编辑“家庭作业”文件夹中的源文本 通常,我知道用Java实现带有关键字“implements”的接口是很困难的。但是我不知道如何在“家庭作业”文件夹中使用它,因为“接口”文件夹已经包含实现接口的方法和逻辑的类,但是我不允许编辑它们 这就是任务: “我们在“接口”包中为您提供各种接口,您必须实现这些接口。您只能在“家庭作业”包中创建自己的实现。您不能修改“接口”包的类和接口 必须实现的接口“TextAdventure”允许您创建一个文本冒险游戏。在“家庭作业”包中,您将找到一个使用TextAdventure接口初始化各种游戏的主类。 成功实现所需的接口后,您可以玩该游戏。游戏场景旨在帮助您全面测试代码。接口播放器的所有方法都可用于与游戏交互。还可以查看GameStarter类。在该类中,实现了与播放器的交互。 TextAdventureInterface提供了创建新游戏的各种方法。对于每种方法,请考虑它可能失败的情况。在这种情况下,抛出TextAdventureException。这也可以在“interfaces”包中使用。一旦建立了所需的初始状态,就可以使用“StartName()”启动游戏 接口:在Java中,是否可以不使用关键字“quot”来实现接口及其方法;实施;?,java,interface,Java,Interface,我有家庭作业要做(实际上是我的女朋友:-D),我能做什么和不能做什么都有一些限制。 在我的NetBeans项目文件夹中,有两个名为“接口”和“家庭作业”的文件夹。 文件夹“interfaces”包含不允许编辑的接口和类,因为xD对我们这样说。 我只允许编辑“家庭作业”文件夹中的源文本 通常,我知道用Java实现带有关键字“implements”的接口是很困难的。但是我不知道如何在“家庭作业”文件夹中使用它,因为“接口”文件夹已经包含实现接口的方法和逻辑的类,但是我不允许编辑它们 这就是任务: “
package interfaces;
import homework.Factory;
/**
* Class with text adventure scenarios to play.
*/
public class Adventures {
/**
* Initialize the fireman-game.
*
* @return the fireman-game
* @throws TextAdventureException
*/
public static interfaces.TextAdventure getFiremanGame() throws TextAdventureException {
interfaces.TextAdventure textAdventure = Factory.getGame("Sample1", 2, 2);
textAdventure.addSceneryType("BurningTree", "A blazing fire on an oak tree.");
textAdventure.addSceneryType("HalfBurningTree", "A little fire on an oak tree.");
textAdventure.addItemType("Bucket", "An empty bucket.");
textAdventure.addItemType("Water", "A bucket full of water.");
textAdventure.addItemType("Head", "Kopf");
textAdventure.addItemType("Headweh", "Jetzt brummt de kopf");
textAdventure.addSceneryType("Lake", "A beautiful lake.");
textAdventure.addSceneryType("CharredOak", "A poor, charred oak tree.");
textAdventure.addTransformation("Bucket", "Lake", "Water", "Lake",
"Now you got a bucket full of water.");
textAdventure.addTransformation("Water", "BurningTree", "HalfBurningTree", "Bucket",
"The water quenches the fire. But not completely.");
textAdventure.addTransformation("Water", "HalfBurningTree", "CharredOak", "Bucket",
"The water quenches the fire.");
textAdventure.addComposition("Bucket", "Head", "Headweh", "Kopfwehh");
textAdventure.placeItem("Lake", 0, 0);
textAdventure.placeItem("Bucket", 1, 1);
textAdventure.placeItem("Head", 1, 1);
textAdventure.placeItem("BurningTree", 0, 0);
return textAdventure;
}
/**
* Initialize the lumberjack-game.
*
* @return The lumberjack-game
* @throws TextAdventureException
*/
public static interfaces.TextAdventure getLumberjackGame() throws TextAdventureException {
interfaces.TextAdventure textAdventure = Factory.getGame("Sample2", 1, 1);
textAdventure.addSceneryType("Tree", "A lush green tree.");
textAdventure.addItemType("Wood", "Some pieces of wood");
textAdventure.addSceneryType("Roots", "The sad roots of a former tree.");
textAdventure.addDecomposition("Tree", "Wood", "Roots", "You fell the tree and get some wood.");
textAdventure.placeItem("Tree", 0, 0);
return textAdventure;
}
/**
* Initialize the pokemon-game.
*
* @return the pokemon-game
* @throws TextAdventureException
*/
public static interfaces.TextAdventure getPokemonGame() throws TextAdventureException {
TextAdventure textAdventure = Factory.getGame("Pokemon", 50, 50);
textAdventure.addItemType("Coin", "One coin");
textAdventure.addItemType("Money", "Many coins");
textAdventure.addItemType("Bisasam", "Look, a wild Bisasam.");
textAdventure.addItemType("Glumanda", "Look, a wild Glumanda.");
textAdventure.addItemType("Schiggy", "Look, a wild Schiggy.");
textAdventure.addItemType("Bisaknosp", "Bisaknosp eats plants.");
textAdventure.addItemType("Glutexo", "Glutexo burns.");
textAdventure.addItemType("Schillok", "Schillok swimming around.");
textAdventure.addItemType("Bisaflor", "Bisaflor eats plants.");
textAdventure.addItemType("Glurak", "Glurak burns.");
textAdventure.addItemType("Turtok", "Turtok swimming around.");
textAdventure.addItemType("Taubsi", "Taubsi flying around.");
textAdventure.addItemType("Tauboga", "Tauboga flying around.");
textAdventure.addItemType("Tauboss", "Tauboss flying around.");
textAdventure.addItemType("Mewtu", "Mewtu sees dead people.");
textAdventure.addItemType("Developmentstone",
"The Developmentstone brings your Pokemon to the next Level.");
textAdventure.addItemType("Attackstone",
"The Attackstone is in combination with your Pokemon to attack other Pokemons.");
textAdventure.addItemType("Pokeball",
"Pokeball is there to catch other Pokemons.");
textAdventure.addSceneryType("Wildtaubsi", "Look, a wild Taubsi.");
textAdventure.addSceneryType("Deadtaubsi", "Look, a dead Taubsi.");
textAdventure.addSceneryType("Silvertreasure", "Look, a Treasure.");
textAdventure.addSceneryType("Goldtreasure", "Look, a Treasure.");
textAdventure.placeItem("Coin", 0, 0);
textAdventure.placeItem("Bisasam", 0, 0);
textAdventure.placeItem("Glumanda", 0, 0);
textAdventure.placeItem("Schiggy", 0, 0);
textAdventure.placeItem("Developmentstone", 2, 4);
textAdventure.placeItem("Developmentstone", 25, 31);
textAdventure.placeItem("Developmentstone", 49, 11);
textAdventure.placeItem("Developmentstone", 22, 22);
textAdventure.placeItem("Developmentstone", 11, 44);
textAdventure.placeItem("Developmentstone", 23, 43);
textAdventure.placeItem("Developmentstone", 39, 1);
textAdventure.placeItem("Developmentstone", 22, 21);
textAdventure.placeItem("Developmentstone", 45, 30);
textAdventure.placeItem("Developmentstone", 10, 12);
textAdventure.placeItem("Developmentstone", 23, 1);
textAdventure.placeItem("Developmentstone", 49, 49);
textAdventure.placeItem("Developmentstone", 17, 15);
textAdventure.placeItem("Attackstone", 1, 1);
textAdventure.placeItem("Attackstone", 10, 10);
textAdventure.placeItem("Attackstone", 20, 20);
textAdventure.placeItem("Attackstone", 30, 30);
textAdventure.placeItem("Attackstone", 4, 5);
textAdventure.placeItem("Attackstone", 10, 2);
textAdventure.placeItem("Attackstone", 23, 44);
textAdventure.placeItem("Attackstone", 30, 35);
textAdventure.placeItem("Pokeball", 1, 1);
textAdventure.placeItem("Pokeball", 3, 22);
textAdventure.placeItem("Pokeball", 17, 21);
textAdventure.placeItem("Pokeball", 33, 13);
textAdventure.placeItem("Pokeball", 45, 22);
textAdventure.placeItem("Pokeball", 21, 13);
textAdventure.placeItem("Pokeball", 19, 41);
textAdventure.placeItem("Pokeball", 12, 32);
textAdventure.placeItem("Wildtaubsi", 2, 2);
textAdventure.placeItem("Wildtaubsi", 23, 24);
textAdventure.placeItem("Wildtaubsi", 11, 7);
textAdventure.placeItem("Wildtaubsi", 3, 9);
textAdventure.placeItem("Wildtaubsi", 32, 45);
textAdventure.placeItem("Wildtaubsi", 31, 29);
textAdventure.placeItem("Wildtaubsi", 17, 31);
textAdventure.placeItem("Wildtaubsi", 45, 45);
textAdventure.placeItem("Wildtaubsi", 18, 32);
textAdventure.placeItem("Wildtaubsi", 26, 42);
textAdventure.placeItem("Wildtaubsi", 42, 26);
textAdventure.placeItem("Wildtaubsi", 17, 49);
textAdventure.placeItem("Wildtaubsi", 11, 22);
textAdventure.placeItem("Wildtaubsi", 36, 39);
textAdventure.placeItem("Wildtaubsi", 31, 24);
textAdventure.placeItem("Silvertreasure", 2, 3);
textAdventure.placeItem("Silvertreasure", 32, 33);
textAdventure.placeItem("Silvertreasure", 14, 13);
textAdventure.placeItem("Silvertreasure", 47, 11);
textAdventure.placeItem("Silvertreasure", 12, 34);
textAdventure.placeItem("Silvertreasure", 21, 33);
textAdventure.placeItem("Silvertreasure", 43, 21);
textAdventure.placeItem("Silvertreasure", 49, 3);
textAdventure.placeItem("Silvertreasure", 12, 49);
textAdventure.placeItem("Silvertreasure", 41, 34);
textAdventure.placeItem("Silvertreasure", 12, 33);
textAdventure.placeItem("Silvertreasure", 22, 34);
textAdventure.placeItem("Silvertreasure", 1, 40);
textAdventure.placeItem("Silvertreasure", 19, 28);
textAdventure.placeItem("Silvertreasure", 45, 32);
textAdventure.placeItem("Silvertreasure", 21, 23);
textAdventure.placeItem("Goldtreasure", 33, 34);
textAdventure.addComposition("Coin", "Coin", "Money", "You made money");
textAdventure.addComposition("Bisasam", "Developmentstone", "Bisaknosp",
"Look your Bisasam has developed to Bisaknosp.");
textAdventure.addComposition("Glumanda", "Developmentstone", "Glutexo",
"Look your Glumanda has developed to Glutexo.");
textAdventure.addComposition("Schiggy", "Developmentstone", "Schillok",
"Look your Schiggy has developed to Schillok.");
textAdventure.addComposition("Taubsi", "Developmentstone", "Tauboga",
"Look your Taubsi has developed to Tauboga");
textAdventure.addComposition("Bisaknosp", "Developmentstone", "Bisaflor",
"Look your Bisaknosp has developed to Bisaflor");
textAdventure.addComposition("Glutexo", "Developmentstone", "Glurak",
"Look your Glutexo has developed to Glurak");
textAdventure.addComposition("Schillok", "Developmentstone", "Turtok",
"Look your Schillok has developed to Turtok");
textAdventure.addComposition("Tauboga", "Developmentstone", "Tauboss",
"Look your Tauboga has developed to Tauboss");
textAdventure.addComposition("Wildtaubsi", "Attackstone", "Deadtaubsi",
"Your Pokemon attacks the wild Taubsi. Taubsi is dead.");
textAdventure.addComposition("Wildtaubsi", "Pokeball", "Taubsi",
"You have catch Taubsi. Congratulations, Taubsi is your new Pokemon.");
textAdventure.addDecomposition("Silvertreasure", "Developmentstone",
"Attackstone",
"You open the treasure and you find an Attack- and Developmentstone.");
textAdventure.addDecomposition("Goldtreasure", "Pokeball", "Mewtu",
"See, you find the unique Mewtu.");
textAdventure.addTransformation("Taubsi", "Attackstone", "Taubsi",
"Developmentstone",
"Look, your Taubsi transform the Attackstone to a Developmentstone.");
textAdventure.addTransformation("Tauboga", "Attackstone", "Tauboga",
"Developmentstone",
"Look, your Tauboga transform the Attackstone to a Developmentstone.");
textAdventure.addTransformation("Tauboss", "Attackstone", "Tauboss",
"Developmentstone",
"Look, your Tauboss transform the Attackstone to a Developmentstone.");
textAdventure.addTransformation("Mewtu", "Developmentstone", "Mewtu",
"Attackstone",
"Look, your Mewtu transform the Developmentstone to a Attackstone.");
textAdventure.addTransformation("Bisasam", "Attackstone", "Bisasam",
"Pokeball",
"Look, your Bisasam transform the Attackstone to a Pokeball.");
textAdventure.addTransformation("Bisaknosp", "Attackstone", "Bisaknosp",
"Pokeball",
"Look, your Bisaknosp transform the Attackstone to a Pokeball.");
textAdventure.addTransformation("Bisaflor", "Attackstone", "Bisaflor",
"Pokeball",
"Look, your Bisaflor transform the Attackstone to a Pokeball.");
textAdventure.addTransformation("Glumanda", "Pokeball", "Glumanda",
"Developmentstone",
"Look, your Glumanda transform the Pokeball to a Developmentstone.");
textAdventure.addTransformation("Glutexo", "Pokeball", "Glutexo",
"Developmentstone",
"Look, your Glutexo transform the Pokeball to a Developmentstone.");
textAdventure.addTransformation("Glurak", "Pokeball", "Glurak",
"Developmentstone",
"Look, your Glurak transform the Pokeball to a Developmentstone.");
textAdventure.addTransformation("Schiggy", "Pokeball", "Schiggy",
"Attackstone",
"Look, your Schiggy transform the Pokeball to a Attackstone.");
textAdventure.addTransformation("Schillok", "Pokeball", "Schillok",
"Attackstone",
"Look, your Schillok transform the Pokeball to a Attackstone.");
textAdventure.addTransformation("Turtok", "Pokeball", "Turtok",
"Attackstone",
"Look, your Turtok transform the Pokeball to a Attackstone.");
return textAdventure;
}
}
package interfaces;
import homework.Factory;
/**
* Class integrates the implementation of the student package and allows to play the text adventure scenarios.
*/
public class GameStarter {
private static final String PROMPT = "play>";
private static Player player;
private Terminal terminal;
private TextAdventure[] games;
/**
* Constructor to create a GameStarter instance.
* @param games array with text adventures games to play
*/
public GameStarter(TextAdventure[] games) {
terminal = Factory.getTerminal();
this.games = games;
}
/**
* Starts one of the given games.
*/
public void startGame() {
String[] input;
String prompt = "Play (";
for (TextAdventure game : this.games) {
prompt += game.getName();
prompt += "|";
}
prompt = prompt.substring(0, prompt.length() - 1) + ")";
do {
terminal.promptInput(prompt);
input = terminal.readInput();
} while (input[0].equals("") || input[0].equals(" "));
String gameName = input[0];
for (TextAdventure game : this.games) {
if (game.getName().equals(gameName)) {
startGame(game, 0, 0);
return;
}
}
System.out.println("Unknown game scenario");
System.exit(1);
}
/**
* Starts a given game and runs a simple input-loop that accepts game-commands.
* @param textAdventure to play
* @param x coordinate of the player
* @param y coordinate of the player
*/
public void startGame(TextAdventure textAdventure, int x, int y) {
try {
player = textAdventure.startGame(x, y);
} catch (TextAdventureException e) {
System.out.println(e.getMessage());
System.exit(1);
}
boolean run = true;
while (run) {
try {
terminal.promptInput(PROMPT);
String[] input = terminal.readInput();
run = processInput(input);
} catch (TextAdventureException e) {
System.out.println(e.getMessage());
}
}
}
/**
* Process the given command-line, translate it into player-actions if possible.
* @param input the splitted user input
* @return false if the user wants to quit, true otherwise
* @throws TextAdventureException If an invalid command is entered
*/
private static boolean processInput(String[] input) throws TextAdventureException {
switch (input[0]) {
case "go": {
if (input.length < 2) {
System.out.println("Sorry, please specify a direction.");
} else {
System.out.println(player.go(input[1]));
}
return true;
}
case "look": {
String[] list = player.look();
for (String line : list) {
System.out.println(line);
}
return true;
}
case "inventory": {
String[] list = player.inventory();
for (String line : list) {
System.out.println(line);
}
return true;
}
case "take": {
if (input.length < 2) {
System.out.println("Sorry, please specify an object.");
} else {
System.out.println(player.take(input[1]));
}
return true;
}
case "drop": {
if (input.length < 2) {
System.out.println("Sorry, please specify an object.");
} else {
System.out.println(player.drop(input[1]));
}
return true;
}
case "convert": {
if (input.length < 3) {
System.out.println("Sorry, please specify the objects to compose.");
} else {
System.out.println(player.convert(input[1], input[2]));
}
return true;
}
case "decompose": {
if (input.length < 2) {
System.out.println("Sorry, please specify an object.");
} else {
System.out.println(player.decompose(input[1]));
}
return true;
}
case "help": {
System.out.println("Valid Commands are: go, look, inventory, take, drop, compose, decompose");
return true;
}
case "exit": {
System.out.println("Bye!");
return false;
}
default: {
throw new TextAdventureException("Unknown Command: " + input[0]);
}
}
}
}
package interfaces;
/**
* Models the interface of a text adventure player.
*/
public interface Player {
/**
* Move the player's token into direction.
* @param direction One of eight valid directions "N", "NE", "E", "SE", "S", "SW", "W", "NW"
* @return A ui-message for the user
*/
String go(String direction);
/**
* Returns an array of objects on the current field.
* @return An array of object-type and descriptions for the ui
*/
String[] look();
/**
* Returns an array of objects in the inventory.
* @return An array of object-type and descriptions for the ui
*/
String[] inventory();
/**
* Removes an object of the given type from the current field and adds it to the inventory.
* @param item An object-type
* @return A ui-message for the user
*/
String take(String item);
/**
* Removes an object of the given type from the inventory and adds it to the current field.
* @param item An object-type
* @return A ui-message for the user
*/
String drop(String item);
/**
* Applies a transformation- or composition-rule to item1 and item2.
* If possible, removes item1 and item2 from the current field or inventory
* and adds the mutation-result to the current field or inventory,
* depending on the object's base-type (scenery or item).
* @param item1 An Object-Type
* @param item2 An Object-Type
* @return A ui-message for the user
*/
String convert(String item1, String item2);
/**
* Applies a decomposition-rule to item.
* If possible, removes item from the current field or inventory
* and adds the mutation-result to the current field or inventory,
* depending on the object's base-type (scenery or item).
* @param item An Object-Type
* @return A ui-message for the user
*/
String decompose(String item);
}
package interfaces;
/**
* Models the interface of terminal to interact with a player.
*/
public interface Terminal {
/**
* Prompts the user to enter a string as input. The string is printed to the standard output (terminal).
*
* @param input the message to display the player
*/
public void promptInput(String input);
/**
* Reads the user input and returns splitted at spaces as string array.
* @return splitted user input string
*/
public String[] readInput();
}
package interfaces;
/**
* Models the interface of a text adventure game-instance.
*/
public interface TextAdventure {
/**
* Declares a new portable object-type with given id and description.
* @param id The id object-type, used in the ui to search for objects
* @param description The description of the object-type
* @throws TextAdventureException Think about the cases in which an exception is useful and implement it.
*/
void addItemType(String id, String description) throws TextAdventureException;
/**
* Declares a new non-portable object-type with given id and description.
* @param id The id object-type, used in the ui to search for objects
* @param description The description of the object-type
* @throws TextAdventureException Think about the cases in which an exception is useful and implement it.
*/
void addSceneryType(String id, String description) throws TextAdventureException;
/**
* Adds a new object of the given type to the field at the specified position.
* @param type The id of an object-type
* @param x A field coordinate on the board
* @param y A field coordinate on the board
* @throws TextAdventureException Think about the cases in which an exception is useful and implement it.
*/
void placeItem(String type, int x, int y) throws TextAdventureException;
/**
* Adds a new composition-rule to the set of mutation-rules.
* @param in1 Object-type id of the input-object
* @param in2 Object-type id of the input-object
* @param out Object-type id of the output-object
* @param description Mutation-description for the ui
* @throws TextAdventureException Think about the cases in which an exception is useful and implement it.
*/
void addComposition(String in1, String in2, String out, String description) throws TextAdventureException;
/**
* Adds a new decomposition-rule to the set of mutation-rules.
* @param in Object-type id of the input-object
* @param out1 Object-type id of the output-object
* @param out2 Object-type id of the output-object
* @param description Mutation-description for the ui
* @throws TextAdventureException Think about the cases in which an exception is useful and implement it.
*/
void addDecomposition(String in, String out1, String out2, String description) throws TextAdventureException;
/**
* Adds a new transformation-rule to the set of mutation-rules.
* @param in1 in1 Object-type id of the input-object
* @param in2 in1 Object-type id of the input-object
* @param out1 Object-type id of the output-object
* @param out2 Object-type id of the output-object
* @param description Mutation-description for the ui
* @throws TextAdventureException Think about the cases in which an exception is useful and implement it.
*/
void addTransformation(String in1, String in2, String out1, String out2, String description)
throws TextAdventureException;
/**
* Initializes a new game instance and returns a player-instance for game-control.
* The player's initial position is at the given coordinates
* @param x A field coordinate on the board
* @param y A field coordinate on the board
* @return A player-instance for game-control
* @throws TextAdventureException Think about the cases in which an exception is useful and implement it.
*/
Player startGame(int x, int y) throws TextAdventureException;
/**
* Returns the name of the game instance.
* @return the name of the game instance
*/
String getName();
}
package interfaces;
/**
* General Exception-type of the text adventure framework.
*/
public class TextAdventureException extends Exception {
/**
* Exception Prefix.
*/
public static final String ERROR = "Error! ";
/**
* Creates a new TextAdventureException with the given message.
* @param message The error-message
*/
public TextAdventureException(String message) {
super(ERROR + message);
}
}
package homework;
/**
* Factory class with functions to generate a game and terminal.
*/
public final class Factory {
private Factory() { }
public static interfaces.TextAdventure getGame(String name, int boardWidth, int boardHeight)
throws interfaces.TextAdventureException {
//placeholder
return null;
}
/**
* Creates a new terminal-instance to read user input and prompt messages.
* @return a terminal instance
*/
public static interfaces.Terminal getTerminal() {
//placeholder
return null;
}
}
}您可以实现接口X声明的所有方法,而无需编写“implements X”。但这真的是荒谬的。您希望Java编译器理解您的新类实现了X,并且您需要在类定义的签名上使用该关键字 可以考虑扩展已经实现接口的类,这样就不必重复关键字“implements X”。但这实际上只是不在源代码中使用该关键字
在您的例子中,关键部分是要理解,到目前为止,并非该包接口中的所有接口都有实现。你的出发点:只写下你收到的输入中存在的类和接口的名称列表。然后看看哪个接口有实现,哪个没有 您对该练习的描述似乎与您提供的代码不匹配。据我所知,
interfaces
包中的类没有提供与所讨论的接口类似的实现(Player
、Terminal
和TextAdventure
)。相反,他们使用这些接口的实现,这些接口是通过调用class家庭作业.Factory
的各种静态方法获得的。你也要去面试你女朋友吗?说真的,帮她做作业会让你感觉很好,但实际上不会帮助她学习。。。或者通过她的考试。。。或者给她找一份需要编程技能的工作。两件事:学习Java中包的概念。仅仅在“文件夹”中思考是不够的。然后:永远不要在注释中提供更多信息,尤其是代码。改为编辑问题。但在你的情况下,你已经有太多的投入了。你必须明白,仅仅凭“现在做什么?”就把一份完整的家庭作业扔掉并不是一个有效的问题。这类作业的要点往往是你需要坐下来,看很多事情,然后谈论这些事情。但这个社区关注的是具体的编程问题。你更应该和其他学生或导师一起工作……注意:你确实说过“我有作业要做(实际上是我的女朋友:-D)”。你可能说错话了。。。是的,在这种情况下,如果我使用关键字“implements”,我必须在那个类中有那个方法。但是老师说游戏和逻辑已经完成了。所以也许我只是不理解作业/任务-(再次强调:到目前为止,并不是所有的课程都已实施。请再次阅读我的答案。再次阅读从其他人那里得到的评论。这真的告诉了你所有需要开始的事情。谢谢,GhostCat。我和我的女朋友做到了。但我现在该怎么办呢?这里有一条信息“这个问题需要更加关注。”我应该现在删除这个问题,因为它太宽泛了,还是我应该将你的答案标记为正确或最有用的答案?我不知道:-(
public static void main(String[] args) {
try {
// Add additional games to the Array
TextAdventure[] games = {
Adventures.getFiremanGame(), Adventures.getLumberjackGame(), Adventures.getPokemonGame()
};
GameStarter starter = new GameStarter(games);
starter.startGame();
} catch (TextAdventureException e) {
e.printStackTrace();
}
}