Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Phase2;
- import javax.swing.JOptionPane;
- import java.io.*;
- import java.util.*;
- import java.text.*;
- public class Phase2
- {//START CLASS
- //START MAIN METHOD
- public static void main(String[] args)
- {
- int[] imember_code=new int[100];
- String[] imember_type=new String[100];
- String[] ifirst_name=new String[100];
- String[] ilast_name=new String[100];
- int[] iage=new int[100];
- String[] igender=new String[100];
- int count1=-1;
- int[] iclass_code=new int[100];
- String[] iclass_name=new String[100];
- String[] ibeginning_date=new String[100];
- int count2=-1;
- int[] iregister_member_code=new int[100];
- int[] iregister_class_code=new int[100];
- int count3=-1;
- count1=Begin_read_member(count1,imember_code,imember_type,ifirst_name,ilast_name,iage,igender);//run only once at beginning before loop, will define code to read in member info
- count2=Begin_read_class(count2,iclass_code,iclass_name,ibeginning_date);//run only once at beginning before loop, will define code to read in class info
- count3=Begin_read_register(count3,iregister_member_code,iregister_class_code);//run only once at beginning before loop, will define code to read in register info
- int selection;
- selection=menu();
- while(selection!=4)
- {
- if (selection == 1)//Add/Modify Member Information
- {
- Modify_member();//functionality added later to add, delete, change basic member info
- }
- else if (selection == 2)//Add/Modify Registrations
- {
- Modify_registration();//functionality added later to add class registration info
- }
- else if (selection == 3)//Report Section
- {
- Report(count1,imember_code,imember_type,ifirst_name,ilast_name,iage,igender,
- count2,iclass_code,iclass_name,ibeginning_date,
- count3,iregister_member_code,iregister_class_code);
- }
- selection =menu();
- }//WHILE LOOP
- Exit_ymca_program();//run only once at end after loop, will write all data back to various files
- System.exit(0);
- }//END MAIN METHOD
- //START MENU METHOD
- public static int menu()
- {
- String mnumber;
- int number;
- String output = "Moon Area YMCA" + " \n " + " \n " +
- "1. Add/Modify Member Information" + " \n " +
- "2. Add/Modify Registrations" + " \n " +
- "3. Report Section" + " \n" + " \n " +
- "4. Exit the System" + " \n" +
- "Please make your selection >";
- mnumber = JOptionPane.showInputDialog(null, output, " ",
- JOptionPane.QUESTION_MESSAGE);
- number=Integer.parseInt(mnumber);
- return number;
- } //END MENU METHOD
- //Modify_member Method Start
- public static void Modify_member()
- {
- System.out.println("Modify_member Method Executed");
- }//Modify_member Method End
- //Modify_registration Method Start
- public static void Modify_registration()
- {
- System.out.println("Modify_registration Method Executed");
- }//Modify_registration Method End
- //Report Method Start
- public static void Report(int count1,int[]imember_code,String[]imember_type,String[]ifirst_name,String[]ilast_name,int[]iage,String[]igender,
- int count2,int[]iclass_code,String[]iclass_name,String[]ibeginning_date,
- int count3,int[]iregister_member_code,int[]iregister_class_code)
- {
- int selection,i;
- String value;
- String output="Moon Area YMCA"+"\n"+
- "=================="+"\n"+
- "1. Basic Member Information"+"\n"+
- "2. Basic Class Information"+"\n"+
- "3. Basic Registration Information"+"\n"+
- "4. Report 4"+"\n"+
- "5. Report 5"+"\n"+
- "6. Report 6"+"\n"+
- "7. Report 7"+"\n"+
- "8. Report 8"+"\n"+
- "9. Report 9"+"\n"+
- "10. Exit Report Menu"+"\n"+
- "Please make your selection > ";
- value =JOptionPane.showInputDialog(null,
- output,"Input Data",JOptionPane.QUESTION_MESSAGE);
- selection=Integer.parseInt(value);
- while(selection!=10)
- {
- if(selection==1)
- {
- System.out.println(" Basic Member Info ");
- System.out.println(" =============");
- for(i=0;i<=count1;++i)
- {
- System.out.println(imember_code[i]+" "+imember_type[i]+" "+ifirst_name[i]+" "+
- ilast_name[i]+" "+iage[i]+" "+igender[i]);
- }
- }
- else
- if(selection==2)
- {
- System.out.println(" Basic Class Info ");
- System.out.println(" =============");
- for(i=0;i<=count2;++i)
- {
- System.out.println(iclass_code[i]+" "+iclass_name[i]+" "+ibeginning_date[i]);
- }
- }
- else
- if(selection==3)
- {
- System.out.println(" Basic Registration Info");
- System.out.println(" ===============");
- for(i=0;i<=count3;++i)
- {
- System.out.println(iregister_member_code[i]+" "+iregister_class_code[i]);
- }
- }
- output="Moon Area YMCA"+"\n"+
- "=================="+"\n"+
- "1. Basic Member Information"+"\n"+
- "2. Basic Class Information"+"\n"+
- "3. Basic Registration Information"+"\n"+
- "4. Report 4"+"\n"+
- "5. Report 5"+"\n"+
- "6. Report 6"+"\n"+
- "7. Report 7"+"\n"+
- "8. Report 8"+"\n"+
- "9. Report 9"+"\n"+
- "10. Exit Report Menu"+"\n"+
- "Please make your selection > ";
- value =JOptionPane.showInputDialog(null,
- output,"Input Data",JOptionPane.QUESTION_MESSAGE);
- selection=Integer.parseInt(value);
- }//end of while loop
- System.out.println("Report Method Executed");
- }//Report Method End
- //Begin_read_member Method Start
- public static int Begin_read_member(int count1,int[]imember_code,String[]imember_type,
- String[]ifirst_name,String[]ilast_name,int[]iage,String[]igender)
- {
- String newLine;
- try
- {
- BufferedReader member_file = new BufferedReader(new FileReader("member.dat"));
- //read lines in file until there are no more lines in the file to read
- while ((newLine = member_file.readLine()) != null)
- {
- //there is a "#" between each data item in each line
- StringTokenizer delimiter = new StringTokenizer(newLine,"#");
- count1=count1+1;
- imember_code[count1] =Integer.parseInt(delimiter.nextToken());
- imember_type[count1] =delimiter.nextToken();
- ifirst_name[count1] =delimiter.nextToken();
- ilast_name[count1] =delimiter.nextToken();
- iage[count1] =Integer.parseInt(delimiter.nextToken());
- igender[count1] =delimiter.nextToken();
- }//while loop
- member_file.close();
- }//end try
- catch (IOException error)
- {
- //there was an error on the file writing
- System.out.println("Error on file read " + error);
- }//error on read
- return count1;
- }//Begin_read_member Method End
- //Begin_read_class Method Start
- public static int Begin_read_class(int count2,int[]iclass_code,String[]iclass_name,
- String[]ibeginning_date)
- {
- String newLine;
- try
- {
- BufferedReader class_file = new BufferedReader(new FileReader("class.dat"));
- //read lines in file until there are no more lines in the file to read
- while ((newLine = class_file.readLine()) != null)
- {
- //there is a "#" between each data item in each line
- StringTokenizer delimiter = new StringTokenizer(newLine,"#");
- count2=count2+1;
- iclass_code[count2] =Integer.parseInt(delimiter.nextToken());
- iclass_name[count2] =delimiter.nextToken();
- ibeginning_date[count2] =delimiter.nextToken();
- }//while loop
- class_file.close();
- }//end try
- catch (IOException error)
- {
- //there was an error on the file writing
- System.out.println("Error on file read " + error);
- }//error on read
- return count2;
- }//Begin_read_class Method End
- //Begin_read_register Method Start
- public static int Begin_read_register(int count3,int[]iregister_member_code,int[]iregister_class_code)
- {
- String newLine;
- try
- {
- BufferedReader register_file = new BufferedReader(new FileReader("register.dat"));
- //read lines in file until there are no more lines in the file to read
- while ((newLine = register_file.readLine()) != null)
- {
- //there is a "#" between each data item in each line
- StringTokenizer delimiter = new StringTokenizer(newLine,"#");
- count3=count3+1;
- iregister_member_code[count3] =Integer.parseInt(delimiter.nextToken());
- iregister_class_code[count3] =Integer.parseInt(delimiter.nextToken());
- }//while loop
- register_file.close();
- }//end try
- catch (IOException error)
- {
- //there was an error on the file writing
- System.out.println("Error on file read " + error);
- }//error on read
- return count3;
- }//Begin_read_register Method End
- //Exit_ymca_program Method Start
- public static void Exit_ymca_program()
- {
- System.out.println("Exit_ymca_program Method Executed");
- }//Exit_ymca_program Method End
- } //END CLASS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement