Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.util.ArrayList;
- import java.util.Scanner;
- import javax.swing.JOptionPane;
- public class DatabaseProject {
- static ArrayList LoricArray = new ArrayList<Loric>();
- public static void readInList() throws Exception{
- Scanner file = new Scanner(new File("./src/listofcharacters"));
- while(file.hasNextLine()){
- String line = file.nextLine();
- String Splitline[] = line.split(",");
- int num = Integer.parseInt(Splitline[0]);
- String name = Splitline[1];
- String leg1 = Splitline[2];
- String leg2 = Splitline[3];
- Loric temp = new Loric(num,name,leg1,leg2);
- System.out.println(temp);
- LoricArray.add(temp);
- }
- System.out.println("Done reading in file.");
- }
- public static void mainMenu() throws Exception{
- String choice = "";
- while(! choice.equals("X")){
- String menu = "Main Menu \n"
- + "A: Read in Data \n"
- + "B: Display Menu \n"
- + "C: Search Menu \n"
- + "X: Exit";
- choice = JOptionPane.showInputDialog(menu);
- if(choice.equals("A"))
- readInList();
- if(choice.equals("B"))
- DisplayMenu();
- if(choice.equals("C"))
- SearchMenu();
- }
- }
- public static void DisplayMenu() throws Exception{
- String choice = "";
- String menu = "Display Menu \n"
- + "A: Display 1 \n"
- + "B: Display 2 \n"
- + "C: Display 3 \n"
- + "X: Exit";
- choice = JOptionPane.showInputDialog(menu);
- if(choice.equals("A"))
- System.out.println("Display 1");
- if(choice.equals("B"))
- System.out.println("Display 2");
- if(choice.equals("C"))
- System.out.println("Display 3");
- }
- public static void SearchMenu() throws Exception{
- String choice = "";
- String menu = "Search Menu \n"
- + "A: Search 1 \n"
- + "B: Search 2 \n"
- + "C: Search 3 \n"
- + "X: Exit";
- choice = JOptionPane.showInputDialog(menu);
- if(choice.equals("A"))
- System.out.println("Search 1");
- if(choice.equals("B"))
- System.out.println("Search 2");
- if(choice.equals("C"))
- System.out.println("Search 3");
- }
- public static void main(String[] args) throws Exception{
- readInList();
- mainMenu();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement