Untitled
unknown
plain_text
2 years ago
2.4 kB
7
Indexable
public class Main { public static ManageProfile ManageProfile; /** * @param args the command line arguments */ public static void main(String[] args) throws ClassNotFoundException { ManageProfile mn = new ManageProfile(); boolean valid = true; do { //check input in menu if have exception try { valid = true; ManageProfile = new ManageProfile(); ManageProfile.createFileOrLoad(); Scanner sc = new Scanner(System.in); int func; do { //repeats menu and will exit when user enters 0 System.out.println("=========Menu========="); System.out.println("1. Add profile."); System.out.println("2. Display profiles."); System.out.println("0. Exit."); System.out.print("Please choice one option: "); func = mn.checkInputIntLimit(); //choose func switch (func) { case 1: ManageProfile.addProfile(); //add profile System.out.println(""); break; case 2: ManageProfile.displayProfile(); //show all profile System.out.println(""); break; case 0: //exit System.out.println("============================="); System.out.println("Thanks for using our program!\n"); ManageProfile.saveFile(); //save file break; // default: // System.out.println("Error: The selection must be from 0 to 2"); } } while (func != 0); //end if choose 0 } catch (IOException e) { System.out.println("Error: The selection must be a number!"); //must be integer System.out.println(e); System.out.println(""); valid = false; } } while (valid == false); } }
Editor is loading...