Advertisement
MnMWizard

db day 4

Feb 9th, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. import java.io.File;
  2. import java.util.ArrayList;
  3. import java.util.Scanner;
  4.  
  5. import javax.swing.JOptionPane;
  6.  
  7. public class DatabaseProject {
  8.  
  9. static ArrayList LoricArray = new ArrayList<Loric>();
  10.  
  11. public static void readInList() throws Exception{
  12. Scanner file = new Scanner(new File("./src/listofcharacters"));
  13. while(file.hasNextLine()){
  14. String line = file.nextLine();
  15. String Splitline[] = line.split(",");
  16. int num = Integer.parseInt(Splitline[0]);
  17. String name = Splitline[1];
  18. String leg1 = Splitline[2];
  19. String leg2 = Splitline[3];
  20. Loric temp = new Loric(num,name,leg1,leg2);
  21. System.out.println(temp);
  22. LoricArray.add(temp);
  23. }
  24. System.out.println("Done reading in file.");
  25. }
  26.  
  27. public static void mainMenu() throws Exception{
  28. String choice = "";
  29. while(! choice.equals("X")){
  30. String menu = "Main Menu \n"
  31. + "A: Read in Data \n"
  32. + "B: Display Menu \n"
  33. + "C: Search Menu \n"
  34. + "X: Exit";
  35. choice = JOptionPane.showInputDialog(menu);
  36. if(choice.equals("A"))
  37. readInList();
  38. if(choice.equals("B"))
  39. DisplayMenu();
  40. if(choice.equals("C"))
  41. SearchMenu();
  42.  
  43. }
  44. }
  45.  
  46. public static void DisplayMenu() throws Exception{
  47. String choice = "";
  48. String menu = "Display Menu \n"
  49. + "A: Display 1 \n"
  50. + "B: Display 2 \n"
  51. + "C: Display 3 \n"
  52. + "X: Exit";
  53. choice = JOptionPane.showInputDialog(menu);
  54. if(choice.equals("A"))
  55. System.out.println("Display 1");
  56. if(choice.equals("B"))
  57. System.out.println("Display 2");
  58. if(choice.equals("C"))
  59. System.out.println("Display 3");
  60.  
  61. }
  62.  
  63.  
  64. public static void SearchMenu() throws Exception{
  65. String choice = "";
  66. String menu = "Search Menu \n"
  67. + "A: Search 1 \n"
  68. + "B: Search 2 \n"
  69. + "C: Search 3 \n"
  70. + "X: Exit";
  71. choice = JOptionPane.showInputDialog(menu);
  72. if(choice.equals("A"))
  73. System.out.println("Search 1");
  74. if(choice.equals("B"))
  75. System.out.println("Search 2");
  76. if(choice.equals("C"))
  77. System.out.println("Search 3");
  78.  
  79. }
  80.  
  81.  
  82. public static void main(String[] args) throws Exception{
  83. readInList();
  84. mainMenu();
  85.  
  86. }
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement