So I am making a text based rpg for a class. Currently the functionality is working for one room which is all I currently want. However I want a more efficient way of doing this. I want to do this without indexes. I want to print a list of elements from the text file from contains(3.a) to the point where end.3 is. Can any of you vets help me? . This is my first attempt at this type of project. The reason I am asking this early is because this is the intro into the project and the final project at the end of the semester will be a parsed 40 page text file.
The text file
1.a
Outside building
-------
WEST 2
UP 2
NORTH 3
IN 3
end.1
2.a
End of road
You are at the end of a road at the top of a small hill.
You can see a small building in the valley to the east.
------
EAST 1
DOWN 2
end.2
3.a
Inside building
You are inside a building, a well house for a large spring
-------
SOUTH 1
OUT 1
end.3
The code
public static void main(String[] args)throws FileNotFoundException{
int direction = 0;
Scanner s = new Scanner(new File("C:\\Users\\Basil Sheppard\\eclipse-workspace\\software practice\\src\\software\\rooms.txt"));
Scanner choice = new Scanner(System.in);
ArrayList<String> listS = new ArrayList<String>();
while ( s.hasNextLine())
listS.add(s.nextLine());
System.out.println("please enter 3 for testing");
direction = choice.nextInt();
switch (direction){
//tests for room 3
case 3: {
boolean found = listS.contains("3.a");
if(found) {
for(int i = 22; i<27; i++) {
System.out.println(listS.get(i));
}
}
}