//Mason Marnell //DatabaseProject import java.io.File; import java.util.ArrayList; import java.util.Scanner; import javax.swing.JOptionPane; public class DatabaseProject { static ArrayList LoricArray = new ArrayList(); 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: Number Legacy 1 Legacy 2 \n" + "B: Number Name Legacy 1 \n" + "C: Name Legacy 1 Legacy 2 \n" + "X: Exit"; choice = JOptionPane.showInputDialog(menu); if(choice.equals("A")) DisplayClass.NumberLegacy1Legacy2(LoricArray); if(choice.equals("B")) DisplayClass.NumberNameLegacy1(LoricArray); if(choice.equals("C")) DisplayClass.NameLegacy1Legacy2(LoricArray); } 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(); } } //--------------------------------------------------------------------------------------------------------------------------- //DisplayClass import java.util.ArrayList; import javax.swing.JOptionPane; public class DisplayClass { public static void NumberLegacy1Legacy2(ArrayList theloric) { String toDisp = ""; for (int i = 0; i < theloric.size(); i++) { toDisp += theloric.get(i).getNumber() + " "; toDisp += theloric.get(i).getLegacy1() + " "; toDisp += theloric.get(i).getLegacy2() + " \n"; } JOptionPane.showMessageDialog(null, toDisp); } public static void NumberNameLegacy1(ArrayList theloric) { String toDisp = ""; for (int i = 0; i < theloric.size(); i++) { toDisp += theloric.get(i).getNumber() + " "; toDisp += theloric.get(i).getName() + " "; toDisp += theloric.get(i).getLegacy1() + " \n"; } JOptionPane.showMessageDialog(null, toDisp); } public static void NameLegacy1Legacy2(ArrayList theloric) { String toDisp = ""; for (int i = 0; i < theloric.size(); i++) { toDisp += theloric.get(i).getName() + " "; toDisp += theloric.get(i).getLegacy1() + " "; toDisp += theloric.get(i).getLegacy2() + " \n"; } JOptionPane.showMessageDialog(null, toDisp); } }