Advertisement
Guest User

clockwork

a guest
Aug 16th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.71 KB | None | 0 0
  1. package Phase2;
  2. import javax.swing.JOptionPane;
  3. import java.io.*;
  4. import java.util.*;
  5. import java.text.*;
  6. public class Phase2
  7. {//START CLASS
  8.  
  9.     //START MAIN METHOD
  10.     public static void main(String[] args)
  11.     {
  12.        
  13.  
  14.         int[] imember_code=new int[100];
  15.         String[] imember_type=new String[100];
  16.         String[] ifirst_name=new String[100];
  17.         String[] ilast_name=new String[100];
  18.         int[] iage=new int[100];
  19.         String[] igender=new String[100];
  20.         int count1=-1;
  21.        
  22.        
  23.         int[] iclass_code=new int[100];
  24.         String[] iclass_name=new String[100];
  25.         String[] ibeginning_date=new String[100];
  26.         int count2=-1;
  27.        
  28.        
  29.         int[] iregister_member_code=new int[100];
  30.         int[] iregister_class_code=new int[100];
  31.         int count3=-1;
  32.            
  33.            
  34.           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
  35.           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
  36.           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
  37.          
  38.               int selection;
  39.               selection=menu();
  40.              
  41.               while(selection!=4)
  42.               {
  43.               if (selection == 1)//Add/Modify Member Information
  44.               {
  45.                   Modify_member();//functionality added later to add, delete, change basic member info
  46.               }
  47.               else if (selection == 2)//Add/Modify Registrations
  48.               {
  49.                   Modify_registration();//functionality added later to add class registration info
  50.               }
  51.               else if (selection == 3)//Report Section
  52.               {
  53.                   Report(count1,imember_code,imember_type,ifirst_name,ilast_name,iage,igender,
  54.                         count2,iclass_code,iclass_name,ibeginning_date,
  55.                         count3,iregister_member_code,iregister_class_code);
  56.               }
  57.               selection =menu();
  58.               }//WHILE LOOP
  59.              
  60.               Exit_ymca_program();//run only once at end after loop, will write all data back to various files
  61.              
  62.               System.exit(0);
  63.     }//END MAIN METHOD
  64.  
  65.    
  66.     //START MENU METHOD
  67.             public static int menu()
  68.             {
  69.               String mnumber;
  70.               int number;
  71.               String output = "Moon Area YMCA" + " \n " + " \n " +
  72.                   "1. Add/Modify Member Information" + " \n " +
  73.                   "2. Add/Modify Registrations" + " \n " +
  74.                   "3. Report Section" + " \n" + " \n " +
  75.                   "4. Exit the System" + " \n" +
  76.                   "Please make your selection  >";
  77.                    mnumber = JOptionPane.showInputDialog(null, output, " ",
  78.                            JOptionPane.QUESTION_MESSAGE);
  79.                    number=Integer.parseInt(mnumber);
  80.                    return number;
  81.             } //END MENU METHOD
  82.  
  83.            
  84.         //Modify_member Method Start
  85.             public static void Modify_member()
  86.             {
  87.                
  88.             System.out.println("Modify_member Method Executed");   
  89.             }//Modify_member Method End
  90.        
  91.            
  92.         //Modify_registration Method Start
  93.             public static void Modify_registration()
  94.             {
  95.             System.out.println("Modify_registration Method Executed"); 
  96.             }//Modify_registration Method End
  97.            
  98.            
  99.         //Report Method Start
  100.             public static void Report(int count1,int[]imember_code,String[]imember_type,String[]ifirst_name,String[]ilast_name,int[]iage,String[]igender,
  101.                     int count2,int[]iclass_code,String[]iclass_name,String[]ibeginning_date,
  102.                     int count3,int[]iregister_member_code,int[]iregister_class_code)
  103.             {
  104.  
  105. int selection,i;
  106. String value;
  107. String output="Moon Area YMCA"+"\n"+
  108.         "=================="+"\n"+
  109.         "1. Basic Member Information"+"\n"+
  110.         "2. Basic Class Information"+"\n"+
  111.         "3. Basic Registration Information"+"\n"+
  112.         "4. Report 4"+"\n"+
  113.         "5. Report 5"+"\n"+
  114.         "6. Report 6"+"\n"+
  115.         "7. Report 7"+"\n"+
  116.         "8. Report 8"+"\n"+
  117.         "9. Report 9"+"\n"+
  118.         "10. Exit Report Menu"+"\n"+
  119.         "Please make your selection > ";
  120.        
  121.          value =JOptionPane.showInputDialog(null,
  122.                     output,"Input Data",JOptionPane.QUESTION_MESSAGE);
  123.          selection=Integer.parseInt(value);
  124.          while(selection!=10)
  125.          {
  126.              if(selection==1)
  127.              {
  128.                  System.out.println("    Basic Member Info ");
  129.                  System.out.println("    =============");
  130.                  for(i=0;i<=count1;++i)
  131.                  {
  132.                             System.out.println(imember_code[i]+"  "+imember_type[i]+"  "+ifirst_name[i]+"  "+
  133.                                    ilast_name[i]+"  "+iage[i]+"  "+igender[i]);
  134.                  }
  135.              }
  136.                
  137.  
  138.              else
  139.                  if(selection==2)
  140.                  {
  141.                      System.out.println("    Basic Class Info ");
  142.                      System.out.println("    =============");
  143.                      for(i=0;i<=count2;++i)
  144.                      {
  145.                                 System.out.println(iclass_code[i]+"  "+iclass_name[i]+"  "+ibeginning_date[i]);
  146.                      }
  147.                  }
  148.              
  149.  
  150.                  else
  151.                      if(selection==3)
  152.                      {
  153.                          System.out.println("       Basic Registration Info");
  154.                          System.out.println("       ===============");
  155.                          for(i=0;i<=count3;++i)
  156.                          {
  157.                              System.out.println(iregister_member_code[i]+"  "+iregister_class_code[i]);
  158.  
  159.                          }   
  160.                      }
  161.              
  162.              output="Moon Area YMCA"+"\n"+
  163.                         "=================="+"\n"+
  164.                         "1. Basic Member Information"+"\n"+
  165.                         "2. Basic Class Information"+"\n"+
  166.                         "3. Basic Registration Information"+"\n"+
  167.                         "4. Report 4"+"\n"+
  168.                         "5. Report 5"+"\n"+
  169.                         "6. Report 6"+"\n"+
  170.                         "7. Report 7"+"\n"+
  171.                         "8. Report 8"+"\n"+
  172.                         "9. Report 9"+"\n"+
  173.                         "10. Exit Report Menu"+"\n"+
  174.                         "Please make your selection > ";
  175.                        
  176.                          value =JOptionPane.showInputDialog(null,
  177.                                     output,"Input Data",JOptionPane.QUESTION_MESSAGE);   
  178.                          selection=Integer.parseInt(value);
  179.          }//end of while loop
  180.  
  181.                
  182.             System.out.println("Report Method Executed");  
  183.             }//Report Method End
  184.            
  185.            
  186.         //Begin_read_member Method Start
  187.             public static int Begin_read_member(int count1,int[]imember_code,String[]imember_type,
  188.                     String[]ifirst_name,String[]ilast_name,int[]iage,String[]igender)
  189.             {
  190.                 String newLine;
  191.                 try
  192.                 {
  193.                    BufferedReader member_file = new BufferedReader(new FileReader("member.dat"));
  194.                    //read lines in file until there are no more lines in the file to read
  195.                    while ((newLine = member_file.readLine()) != null)
  196.                      {
  197.                        //there is a "#" between each data item in each line
  198.                         StringTokenizer delimiter = new StringTokenizer(newLine,"#");
  199.                         count1=count1+1;
  200.                         imember_code[count1] =Integer.parseInt(delimiter.nextToken());
  201.                         imember_type[count1] =delimiter.nextToken();
  202.                         ifirst_name[count1] =delimiter.nextToken();
  203.                         ilast_name[count1] =delimiter.nextToken();
  204.                         iage[count1] =Integer.parseInt(delimiter.nextToken());
  205.                         igender[count1] =delimiter.nextToken();
  206.                       }//while loop
  207.                      member_file.close();
  208.                   }//end try
  209.                   catch (IOException error)
  210.                 {
  211.                 //there was an error on the file writing
  212.                 System.out.println("Error on file read " + error);
  213.                 }//error on read
  214.                 return count1;
  215.             }//Begin_read_member Method End
  216.            
  217.            
  218.         //Begin_read_class Method Start
  219.             public static int Begin_read_class(int count2,int[]iclass_code,String[]iclass_name,
  220.                     String[]ibeginning_date)
  221.             {
  222.                 String newLine;
  223.                 try
  224.                 {
  225.                    BufferedReader class_file = new BufferedReader(new FileReader("class.dat"));
  226.                    //read lines in file until there are no more lines in the file to read
  227.                    while ((newLine = class_file.readLine()) != null)
  228.                      {
  229.                        //there is a "#" between each data item in each line
  230.                         StringTokenizer delimiter = new StringTokenizer(newLine,"#");
  231.                         count2=count2+1;
  232.                         iclass_code[count2] =Integer.parseInt(delimiter.nextToken());
  233.                         iclass_name[count2] =delimiter.nextToken();
  234.                         ibeginning_date[count2] =delimiter.nextToken();
  235.                       }//while loop
  236.                      class_file.close();
  237.                   }//end try
  238.                   catch (IOException error)
  239.                 {
  240.                 //there was an error on the file writing
  241.                 System.out.println("Error on file read " + error);
  242.                 }//error on read
  243.                 return count2; 
  244.             }//Begin_read_class Method End
  245.            
  246.            
  247.         //Begin_read_register Method Start
  248.             public static int Begin_read_register(int count3,int[]iregister_member_code,int[]iregister_class_code)
  249.             {
  250.                 String newLine;
  251.                 try
  252.                 {
  253.                    BufferedReader register_file = new BufferedReader(new FileReader("register.dat"));
  254.                    //read lines in file until there are no more lines in the file to read
  255.                    while ((newLine = register_file.readLine()) != null)
  256.                      {
  257.                        //there is a "#" between each data item in each line
  258.                         StringTokenizer delimiter = new StringTokenizer(newLine,"#");
  259.                         count3=count3+1;
  260.                         iregister_member_code[count3] =Integer.parseInt(delimiter.nextToken());
  261.                         iregister_class_code[count3] =Integer.parseInt(delimiter.nextToken());
  262.                       }//while loop
  263.                      register_file.close();
  264.                   }//end try
  265.                   catch (IOException error)
  266.                 {
  267.                 //there was an error on the file writing
  268.                 System.out.println("Error on file read " + error);
  269.                 }//error on read
  270.                 return count3;             
  271.             }//Begin_read_register Method End
  272.            
  273.            
  274.         //Exit_ymca_program Method Start
  275.             public static void Exit_ymca_program()
  276.             {
  277.             System.out.println("Exit_ymca_program Method Executed");   
  278.             }//Exit_ymca_program Method End
  279.            
  280.            
  281. } //END CLASS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement