我正在创建一个选择你自己的冒险“游戏”作为小组项目的一部分。我的想法是创建一个 StoryRoom 类型的对象,它将存储诸如对该 StoryRoom 的描述、其他 StoryRoom 连接到它的信息等信息。我还希望有一个类来创建一个冒险,这将是 StoryRoom 的数组. 这个想法是主程序将在 StoryRoom 中循环,显示文本并在做出决定时返回一个值,该值将作为下一个 StoryRoom 的参考,直到玩家到达结束场景。
我遇到的问题是我无法通过 AdventureTeller 类访问在 AdventureBuilder 类中创建的 StoryRooms。AdventureTeller 是游戏的驱动程序类。Eclipse 抛出 entryway 无法解析为变量的错误。我怎样才能解决这个问题?
public class StoryRoom {
    public String[] description = null;
    public int[] exits;
    public StoryRoom(String[] builddescriptions, int[] buildexits){
        description = new String[builddescriptions.length];
        exits = new int[buildexits.length];
        for (int i = 0; i< builddescriptions.length; i++){
            description[i] = builddescriptions[i];
        }
        for (int i = 0; i< buildexits.length; i++){
            exits[i] = buildexits[i];
        }
    }
    public String GetDescription(int reference){
        return description[reference];
    }
    public int GetExit(int reference){
        return exits[reference];
    }
}
public class AdventureTeller {
    public static void main(String[] args) {
        AdventureBuilder.main();
        for (int i = 0; i < entryway.description.length; i++)
        {
            System.out.println(entryway.GetDescription(i));
        }
    }
}
public class AdventureBuilder {
    public static void main() {
        // StoryRoom[] book = new StoryRoom[20];
        String[] description = null;
        description = new String[3];
        int[] exits;
        exits = new int[3];
        description[0] = "This is a strange room with 2 doors, one on the left and one on the right.";
        description[1] = "Take the left door? (enter 1)";
        description[2] = "Take the right door? (enter 2)";
        exits[0] = 1; // current room number
        exits[1] = 2;
        exits[2] = 3;
        StoryRoom entryway = new StoryRoom(description, exits);
    }
}