Guest User

Untitled

a guest
Nov 17th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import io.*;
  2. import java.io.*;
  3.  
  4. public class TextAdventure
  5. {
  6.  
  7. private TextFile text;
  8. private Choices option;
  9. private String directory;
  10.  
  11. public TextAdventure (String folder)
  12. {
  13. directory = folder;
  14. text = new TextFile(directory+"/START.txt");
  15. option = new Choices(directory+"/START_opt.csv");
  16. }
  17.  
  18. public void printCase()
  19. {
  20. text.printStory();
  21. option.printOptions();
  22. }
  23.  
  24. public void getNextScene(int choice)
  25. {
  26. int lastIdx;
  27. String next;
  28.  
  29. if(choice > option.getNumChoices())
  30. {
  31. throw new IllegalArgumentException("Invalid choice.");
  32. }
  33. else
  34. {
  35. lastIdx = option.getLastIdx(choice -1);
  36. next = option.nextScene((choice -1) , lastIdx);
  37.  
  38. text.readScene(next+".txt");
  39. option.readOptions(next+"_opt.csv");
  40.  
  41. }
  42.  
  43. }
  44.  
  45. }
Add Comment
Please, Sign In to add comment