Advertisement
Guest User

Console java Class

a guest
Jun 25th, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. public class Console {
  2. private String[] commands = new String[] {
  3. // All of your commands here
  4. },
  5. lines = new String[1000];
  6. // 1000, just b/c you probably won't top that any time soon...
  7.  
  8. // Now for the character that will appear first on the command line, like: #
  9. // open EVEIL_PLANZ.txt
  10. private String forechar = ""; // Make it something like $, or %, or even
  11. // #...
  12. private int currentline = 1;
  13.  
  14. private ArrayList<File> files = null;
  15.  
  16. public Console(String init_text, ArrayList<File> files) {
  17. this.files = files;
  18. initText(init_text);
  19. }
  20.  
  21. // Makes the first line of text appear, i.e. Hello, I am HAL 9000,
  22. // Heuristically programmed ALgorithmic computer
  23. public void initText(String init_text) {
  24. lines[0] = init_text;
  25. currentline++;
  26. }
  27.  
  28. // Should be input by something. Something that you can do.
  29. public void enter(String command) {
  30. for(String tempcommand : commands)
  31. if()//Check if the command matches any in database
  32. //Do whatever you want that command to do, like, openFile()
  33. //Move up on the current line!
  34. currentline++;
  35. lines[currentline] = forechar;
  36. }
  37.  
  38. // Render all of the lines! Should be called by computer entity or something
  39. // lower in the hierarchy...
  40. public void renderScreen() {
  41. }
  42.  
  43. //Used to open a file...
  44. public void openFile(File file) {
  45. lines[currentline] = "FILE DUMP: " + file.getContents();
  46. }
  47.  
  48. // Basically just a file that you can open.
  49. private class File {
  50. private String contents = "UNEDITED";
  51.  
  52. public File(String contents) {
  53. this.contents = contents;
  54. }
  55.  
  56. public String getContents() {
  57. return contents;
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement