Guest User

Untitled

a guest
Jul 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 16.85 KB | None | 0 0
  1. /** Project 1 COP 3503
  2.  
  3.  *
  4.  
  5.  * @author shayan
  6.  
  7.  *
  8.  
  9.  */
  10.  
  11.  
  12.  
  13. import java.util.*;
  14.  
  15. import java.io.*;
  16. import java.util.Scanner;
  17. import java.util.ArrayList;
  18.  
  19.  
  20.  
  21. public class University {
  22.  
  23.     // Properties
  24.  
  25.     private String name;
  26.  
  27.     private String currentTerm; // Fall/Spring/etc.
  28.  
  29.     private int year;           // 2011...
  30.  
  31.    
  32.  
  33.     private Course[] courses;
  34.  
  35.     private Student[] students;
  36.  
  37.     private Instructor[] instructors;
  38.  
  39.    
  40.  
  41.     // Constructors
  42.  
  43.     public University(String name, String currentTerm, int year, Student[] students, Instructor[] instructors, Course[] courses) {
  44.  
  45.         this.name = name;
  46.  
  47.         this.currentTerm = currentTerm;
  48.  
  49.         this.year = year;
  50.  
  51.        
  52.  
  53.         this.students = students;
  54.  
  55.         this.courses = courses;
  56.  
  57.         this.instructors = instructors;
  58.  
  59.     }
  60.  
  61.  
  62.  
  63.     // Get/set
  64.  
  65.     public String getName() {
  66.  
  67.         return name;
  68.  
  69.     }
  70.  
  71.  
  72.  
  73.     public void setName(String name) {
  74.  
  75.         this.name = name;
  76.  
  77.     }
  78.  
  79.  
  80.  
  81.     public String getCurrentTerm() {
  82.  
  83.         return currentTerm;
  84.  
  85.     }
  86.  
  87.  
  88.  
  89.     public void setCurrentTerm(String currentTerm) {
  90.  
  91.         this.currentTerm = currentTerm;
  92.  
  93.     }
  94.  
  95.  
  96.  
  97.     public int getYear() {
  98.  
  99.         return year;
  100.  
  101.     }
  102.  
  103.  
  104.  
  105.     public void setYear(int year) {
  106.  
  107.         this.year = year;
  108.  
  109.     }
  110.  
  111.  
  112.  
  113.     public Course[] getCourses() {
  114.  
  115.         return courses;
  116.  
  117.     }
  118.  
  119.  
  120.  
  121.     public void setCourses(Course[] courses) {
  122.  
  123.         this.courses = courses;
  124.  
  125.     }
  126.  
  127.  
  128.  
  129.     public Student[] getStudents() {
  130.  
  131.         return students;
  132.  
  133.     }
  134.  
  135.  
  136.  
  137.     public void setStudents(Student[] students) {
  138.  
  139.         this.students = students;
  140.  
  141.     }
  142.  
  143.  
  144.  
  145.     public Instructor[] getInstructors() {
  146.  
  147.         return instructors;
  148.  
  149.     }
  150.  
  151.  
  152.  
  153.     public void setInstructors(Instructor[] instructors) {
  154.  
  155.         this.instructors = instructors;
  156.  
  157.     }
  158.  
  159.  
  160.  
  161.     public boolean writeToFile(String filename) {
  162.  
  163.         PrintWriter output = null;
  164.  
  165.  
  166.  
  167.         try {
  168.  
  169.             output = new PrintWriter(new File(filename));
  170.  
  171.             output.print("University Name: "); output.println(this.name);
  172.  
  173.             output.print("Current Term: "); output.println(this.currentTerm);
  174.  
  175.             output.print("Current Year: "); output.println(this.year);
  176.  
  177.             output.print("Number of Students: "); output.println(students.length);
  178.  
  179.             output.print("Number of Instructors: "); output.println(instructors.length);
  180.  
  181.             output.print("Number of Courses: "); output.println(courses.length);
  182.  
  183.                 for(int i=0; i<students.length; i++) {
  184.  
  185.                     if(students[i] instanceof UndergradStudent) {
  186.  
  187.                         output.println("Undergrad Student:");
  188.  
  189.                     }
  190.  
  191.                         else if(students[i] instanceof GradStudent) {
  192.  
  193.                         output.println("Grad Student:");
  194.  
  195.                     }
  196.  
  197.                     output.print("Name: "); output.println(students[i].getName());
  198.  
  199.                     output.print("UFID: "); output.println(students[i].getUFID());
  200.  
  201.                     output.print("D.O.B: "); output.println(students[i].getDob());
  202.  
  203.                     output.print("GPA: "); output.println(students[i].getGpa());
  204.  
  205.                     output.print("Number of Courses: "); output.println(students[i].getNumCoursesEnrolled());
  206.  
  207.                 }
  208.  
  209.                 for(int i = 0; i<instructors.length; i++) {
  210.  
  211.                     output.println("Instructor:");
  212.  
  213.                     output.print("Name: "); output.println(instructors[i].getName());
  214.  
  215.                     output.print("UFID: "); output.println(instructors[i].getUFID());
  216.  
  217.                     output.print("D.O.B: "); output.println(instructors[i].getDob());
  218.  
  219.                 }
  220.  
  221.                 for(int i = 0; i<courses.length; i++) {
  222.                     if(courses[i] != null) {
  223.  
  224.                         output.println("Course:");
  225.  
  226.                         output.print(courses[i].getType()); output.println(courses[i].getNumber());
  227.  
  228.                         output.println(courses[i].getTitle());
  229.  
  230.                         output.print("Number of Credits: "); output.println(courses[i].getNumCredits());
  231.  
  232.                         output.print("Instructor UFID: "); output.println(courses[i].getInstructor().getUFID());
  233.  
  234.                         output.print("Number of TAs: "); output.println(courses[i].getTAs().length);
  235.  
  236.                         output.print("TA UFIDs: ");
  237.  
  238.                             for(int j = 0; j<courses[i].getTAs().length; j++) {
  239.                            
  240.  
  241.                                 output.print(courses[i].getTAs()[j].getUFID());
  242.                                     if(j<courses[i].getTAs().length-1) {
  243.                                         output.print(",");
  244.                                     }
  245.  
  246.                             }
  247.  
  248.                         output.println(" ");
  249.  
  250.                         output.print("Capacity: "); output.println(courses[i].getCapacity());
  251.  
  252.                         output.print("Current Enrollment: "); output.println(courses[i].getCurrentEnrollment());
  253.  
  254.                         output.print("Student UFIDs: ");
  255.  
  256.                             for(int k = 0; k<courses[i].getStudents().length; k++) {
  257.                                 if(courses[i].getStudents()[k] != null) {
  258.  
  259.                                     output.print(courses[i].getStudents()[k].getUFID());
  260.                                         if(k<courses[i].getStudents().length-1) {
  261.                                             output.print(",");
  262.                                         }
  263.                                 }
  264.  
  265.                             }
  266.  
  267.                         output.println(" ");
  268.                     }
  269.  
  270.                    
  271.  
  272.                 }
  273.  
  274.                    
  275.  
  276.                 output.flush();
  277.  
  278.         }
  279.  
  280.        
  281.  
  282.         catch(IOException ioe) {
  283.  
  284.             System.out.println(ioe.toString());
  285.  
  286.         }
  287.  
  288.    
  289.  
  290.         finally {
  291.  
  292.             if (output != null){
  293.  
  294.                         output.close();
  295.  
  296.                         return true;
  297.  
  298.             }
  299.  
  300.         }
  301.  
  302.         return false;
  303.  
  304.     }
  305.  
  306.  
  307.  
  308.            
  309.     public static University readFromFile(String filename) {
  310.        
  311.         String line1 = "";
  312.         File inFile = new File(filename);
  313.         Scanner in = null;
  314.         String line2 = "";
  315.         ArrayList<UndergradStudent> undergrads2 = new ArrayList<UndergradStudent>();
  316.         ArrayList<GradStudent> grads2 = new ArrayList<GradStudent>();
  317.         ArrayList<Course> courses2 = new ArrayList<Course>();
  318.         ArrayList<Instructor> instructors2 = new ArrayList<Instructor>();
  319.         ArrayList<Student> students2 = new ArrayList<Student>();
  320.         String studentName = "";
  321.         int studentUFID = 0;
  322.         String studentDOB = "";
  323.         double studentGPA = 0.0;
  324.         int studentNumCourses = 0;
  325.         String instructorName = "";
  326.         int instructorUFID = 0;
  327.         String instructorDOB = "";
  328.         String courseType = "";
  329.         int courseNumber = 0;
  330.         String courseTitle = "";
  331.         int numOfCredits = 0;
  332.         int courseInstructorUFID = 0;
  333.         int numOfTAs = 0;
  334.         int taUFID = 0;
  335.         int courseCapacity = 0;
  336.         int currentEnrollment = 0;
  337.     try {
  338.        
  339.         in = new Scanner(inFile);
  340.                
  341.                 if ((line1 = in.nextLine()) == null) {
  342.                     throw new EmptyFileException(filename);
  343.                 }
  344.        
  345.        
  346.         String[] tokens = line1.split(" ");
  347.             for(int i = 2; i<tokens.length; i++) {
  348.                 line2 += tokens[i];
  349.                     if (i<tokens.length-1) {
  350.                         line2 += " ";
  351.                     }
  352.             }  
  353.         String universityName = line2;
  354.         line2 = "";
  355.    
  356.         line1 = in.nextLine();
  357.         String[] tokens2 = line1.split(" ");
  358.             for(int i = 2; i<tokens2.length; i++) {
  359.                 line2 += tokens2[i];
  360.             }
  361.         String currentTerm = line2;
  362.         line2 = "";
  363.  
  364.         line1 = in.nextLine();
  365.         String[] tokens3 = line1.split(" ");
  366.             for(int i = 2; i<tokens3.length; i++) {
  367.                 line2 += tokens3[i];
  368.             }
  369.         int currentYear = Integer.parseInt(line2);
  370.         line2 = "";
  371.  
  372.         line1 = in.nextLine();
  373.         String[] tokens4 = line1.split(" ");
  374.             for(int i = 3; i<tokens4.length; i++) {
  375.                 line2 += tokens4[i];
  376.             }
  377.         int numberOfStudents = Integer.parseInt(line2);
  378.         line2 = "";
  379.         Student[] students = new Student[numberOfStudents];
  380.        
  381.        
  382.  
  383.         line1 = in.nextLine();
  384.         String[] tokens5 = line1.split(" ");
  385.             for(int i = 3; i<tokens5.length; i++) {
  386.                 line2 += tokens5[i];
  387.             }
  388.         int numberOfInstructors = Integer.parseInt(line2);
  389.         line2 = "";
  390.         Instructor[] instructors = new Instructor[numberOfInstructors];
  391.  
  392.  
  393.  
  394.         line1 = in.nextLine();
  395.         String[] tokens6 = line1.split(" ");
  396.             for(int i = 3; i<tokens6.length; i++) {
  397.                 line2 += tokens6[i];
  398.             }
  399.         int numberOfCourses = Integer.parseInt(line2);
  400.         line2 = "";
  401.         Course[] courses = new Course[numberOfCourses];
  402.  
  403.         for(int i = 0; i<numberOfStudents; i++) {
  404.             int count = 0;
  405.             line1 = in.nextLine();
  406.                 if(line1.equals("Undergrad Student:")) {
  407.                             line1 = in.nextLine();
  408.                             String[] tokens7 = line1.split(" ");
  409.                                 for(int a = 1; a < tokens7.length; a++){
  410.                                     line2 += tokens7[a];
  411.                                     if (a<tokens7.length-1) {
  412.                                         line2 += " ";
  413.                                 }
  414.                                     }  
  415.                             studentName = line2;
  416.                             line2 = "";
  417.                
  418.                             line1 = in.nextLine();
  419.                             String[] tokens8 = line1.split(" ");
  420.                                 for(int b = 1; b<tokens8.length; b++) {
  421.                                     line2 += tokens8[b];
  422.                                 }
  423.                             studentUFID = Integer.parseInt(line2);
  424.                             line2 = "";
  425.    
  426.                             line1 = in.nextLine();
  427.                             String[] tokens9 = line1.split(" ");
  428.                                 for(int c = 1; c<tokens9.length; c++) {
  429.                                     line2 += tokens9[c];
  430.                                 }
  431.                             studentDOB = line2;
  432.                             line2 = "";
  433.    
  434.                             line1 = in.nextLine();
  435.                             String[] tokens10 = line1.split(" ");
  436.                                 for(int d = 1; d<tokens10.length; d++){
  437.                                     line2 += tokens10[d];
  438.                                 }
  439.                             studentGPA = Double.parseDouble(line2);
  440.                             line2 = "";
  441.  
  442.                             line1 = in.nextLine();
  443.                             String[] tokens11 = line1.split(" ");
  444.                                 for(int e =3; e<tokens11.length; e++) {
  445.                                     line2 += tokens11[e];
  446.                                 }
  447.                             studentNumCourses = Integer.parseInt(line2);
  448.                             line2 = "";
  449.  
  450.                     UndergradStudent underGradStudent = new UndergradStudent(studentName, studentUFID, studentDOB, studentGPA);
  451.                     undergrads2.add(underGradStudent);
  452.         }
  453.  
  454.                 else if(line1.equals("Grad Student:")) {
  455.  
  456.                                 line1 = in.nextLine();
  457.                             String[] tokens7 = line1.split(" ");
  458.                                 for(int a = 1; a < tokens7.length; a++){
  459.                                     line2 += tokens7[a];
  460.                                     if (a<tokens7.length-1) {
  461.                                         line2 += " ";
  462.                                 }
  463.                                     }  
  464.                             studentName = line2;
  465.                             line2 = "";
  466.                
  467.                             line1 = in.nextLine();
  468.                             String[] tokens8 = line1.split(" ");
  469.                                 for(int b = 1; b<tokens8.length; b++) {
  470.                                     line2 += tokens8[b];
  471.                                 }
  472.                             studentUFID = Integer.parseInt(line2);
  473.                             line2 = "";
  474.    
  475.                             line1 = in.nextLine();
  476.                             String[] tokens9 = line1.split(" ");
  477.                                 for(int c = 1; c<tokens9.length; c++) {
  478.                                     line2 += tokens9[c];
  479.                                 }
  480.                             studentDOB = line2;
  481.                             line2 = "";
  482.    
  483.                             line1 = in.nextLine();
  484.                             String[] tokens10 = line1.split(" ");
  485.                                 for(int d = 1; d<tokens10.length; d++){
  486.                                     line2 += tokens10[d];
  487.                                 }
  488.                             studentGPA = Double.parseDouble(line2);
  489.                             line2 = "";
  490.  
  491.                             line1 = in.nextLine();
  492.                             String[] tokens11 = line1.split(" ");
  493.                                 for(int e =3; e<tokens11.length; e++) {
  494.                                     line2 += tokens11[e];
  495.                                 }
  496.                             studentNumCourses = Integer.parseInt(line2);
  497.                             line2 = "";
  498.  
  499.                     GradStudent gradStudent = new GradStudent(studentName, studentUFID, studentDOB, studentGPA);
  500.                     grads2.add(gradStudent);
  501.             }
  502.         }
  503.  
  504.  
  505.  
  506.  
  507.         for(int x = 0; x < numberOfInstructors; x++) {
  508.             line1 = in.nextLine(); 
  509.             line1 = in.nextLine();
  510.                 String[] tokens12 = line1.split(" ");
  511.                         for(int f = 1; f < tokens12.length; f++){
  512.                             line2 += tokens12[f];
  513.                                 if (f<tokens12.length-1) {
  514.                                     line2 += " ";
  515.                                 }
  516.                         }
  517.                             instructorName = line2;
  518.                             line2 = "";
  519.  
  520.             line1 = in.nextLine();
  521.                 String[] tokens13 = line1.split(" ");
  522.                     for(int g = 1; g<tokens13.length; g++){
  523.                         line2 += tokens13[g];
  524.                     }
  525.                     instructorUFID = Integer.parseInt(line2);
  526.                     line2 = "";
  527.  
  528.             line1 = in.nextLine();
  529.                 String[] tokens14 = line1.split(" ");
  530.                     for(int h = 1; h<tokens14.length; h++){
  531.                         line2 += tokens14[h];
  532.                     }
  533.                     instructorDOB = line2;     
  534.                     line2 = "";
  535.  
  536.             Instructor instructor = new Instructor(instructorName, instructorUFID, instructorDOB);
  537.            
  538.                 for(int ab = 0; ab <instructors.length; ab++) {
  539.                     if(instructors[ab] == null) {
  540.                         instructors[ab] = instructor; break;
  541.                     }
  542.                 }
  543.         }
  544.  
  545.  
  546.        
  547.         for(int z = 0; z<numberOfCourses; z++) {
  548.                 line1 = in.nextLine();
  549.                 line1 = in.nextLine();
  550.                     String[] tokens15 = line1.split(" ");
  551.                     courseType = tokens15[0];
  552.                     courseNumber = Integer.parseInt(tokens15[1]);
  553.  
  554.                 line1 = in.nextLine();
  555.                 courseTitle = line1;
  556.                    
  557.                 line2 = "";
  558.                 line1 = in.nextLine();
  559.                 String[] tokens16 = line1.split(" ");
  560.                     for(int j = 3; j<tokens16.length; j++){
  561.                         line2 += tokens16[j];
  562.                     }
  563.                     numOfCredits = Integer.parseInt(line2);
  564.                     line2 = "";
  565.  
  566.        
  567.  
  568.                
  569.        
  570.                 line1 = in.nextLine();
  571.                 String[] tokens17 = line1.split(" ");
  572.                     for(int k = 2; k<tokens17.length; k++){
  573.                         line2 += tokens17[k];
  574.                     }
  575.                     courseInstructorUFID = Integer.parseInt(line2);
  576.                     line2 = "";
  577.                
  578.                 line1 = in.nextLine();
  579.                 String[] tokens18 = line1.split(" ");
  580.                     for(int l = 3; l<tokens18.length; l++) {
  581.                         line2 += tokens18[l];
  582.                     }
  583.                     numOfTAs = Integer.parseInt(line2);
  584.                     line2 = "";
  585.                     int[] TAUFIDs = new int[numOfTAs];
  586.  
  587.                 line1 = in.nextLine();
  588.                 String[] tokens19 = line1.split(" ");
  589.                 for(int n = 2; n<tokens19.length; n++) {
  590.                             line2 += tokens19[n];
  591.                 }
  592.                         String[] tokens20 = line2.split(",");
  593.  
  594.                     if(tokens20.length < 2) {
  595.                         taUFID = Integer.parseInt(line2);
  596.                         TAUFIDs[0] = taUFID;
  597.                     }
  598.                     else {
  599.                        
  600.                         for(int o =0; o<tokens20.length; o++) {
  601.                             TAUFIDs[o] = Integer.parseInt(tokens20[o]);
  602.                         }
  603.                     }
  604.                 line2 = "";
  605.    
  606.                 line1 = in.nextLine();
  607.                 String[] tokens21 = line1.split(" ");  
  608.                     for(int p = 1; p<tokens21.length; p++){
  609.                         line2 += tokens21[p];
  610.                     }
  611.                 courseCapacity = Integer.parseInt(line2);
  612.                 line2 = "";
  613.                 int[] studentUFIDs = new int[currentEnrollment];
  614.                
  615.  
  616.  
  617.  
  618.        
  619.         Course course = new Course(courseType, courseNumber, courseTitle, numOfCredits);
  620.  
  621.         GradStudent[] TAs = new GradStudent[numOfTAs]; 
  622.  
  623.                    
  624.                
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.                
  633.                    
  634.  
  635.                     for(int ee = 0; ee<instructors.length; ee++) {
  636.                         if(instructors[ee].getUFID() == courseInstructorUFID) {
  637.                             course.setInstructor(instructors[ee]);
  638.                             instructors[ee].setCourse(course);
  639.                         }
  640.                     }
  641.  
  642.  
  643.  
  644.  
  645.                 line1 = in.nextLine();
  646.                 String[] tokens22 = line1.split(" ");  
  647.                     for(int q = 2; q<tokens22.length; q++) {
  648.                         line2 += tokens22[q];
  649.                     }
  650.                 currentEnrollment = Integer.parseInt(line2);
  651.                 line2 = "";
  652.                
  653.                        
  654.                 line1 = in.nextLine();
  655.                     String[] tokens23 = line1.split(" ");
  656.                 for(int r = 2; r<tokens23.length; r++) {
  657.                             line2 += tokens23[r];
  658.                 }
  659.                         String[] tokens24 = line2.split(",");
  660.  
  661.                     if(tokens24.length < 2) {
  662.                         studentUFID = Integer.parseInt(line2);
  663.                         studentUFIDs[0] = studentUFID;
  664.                     }
  665.                     else {
  666.                        
  667.                         for(int s =0; s<studentUFIDs.length; s++) {
  668.                             studentUFIDs[s] = Integer.parseInt(tokens24[s]);
  669.                         }
  670.                     }
  671.  
  672.         course.setCapacity(courseCapacity);
  673.  
  674.                 for(int u = 0; u < grads2.size(); u++) {
  675.                     for(int w = 0; w < studentUFIDs.length; w++) {
  676.                        
  677.                             if(grads2.get(u).getUFID() == studentUFIDs[w]){
  678.                                 grads2.get(u).addCourse(course);
  679.                                 course.addStudent(grads2.get(u));
  680.                             }
  681.                        
  682.                     }
  683.                 }
  684.  
  685.  
  686.                
  687.                 for(int ux = 0; ux < undergrads2.size(); ux++) {
  688.                     for(int wx = 0; wx < studentUFIDs.length; wx++) {
  689.                        
  690.                             if(undergrads2.get(ux).getUFID() == studentUFIDs[wx]){
  691.                                 undergrads2.get(ux).addCourse(course);
  692.                                 course.addStudent(undergrads2.get(ux));
  693.                             }
  694.                        
  695.                     }
  696.                 }
  697.  
  698.  
  699.    
  700.  
  701.  
  702.  
  703.  
  704.    
  705.  
  706. course.setCapacity(courseCapacity);
  707.    
  708.         for(int gg = 0; gg<grads2.size(); gg++) {
  709.                     for(int hh = 0; hh<TAUFIDs.length; hh++){
  710.                         if(grads2.get(gg) != null && grads2.get(gg).getUFID() == TAUFIDs[hh]){
  711.                             grads2.get(gg).setCourseTA(course);
  712.                                 for(int xx = 0; xx < TAs.length; xx++){
  713.                                     if(TAs[xx] == null) {
  714.                                         TAs[xx] = grads2.get(gg);break;
  715.                                     }
  716.                                 }
  717.                         }
  718.                     }
  719.         }
  720.        
  721.         course.setTAs(TAs);
  722.  
  723.  
  724.  
  725.  
  726.            
  727.  
  728.  
  729.  
  730.  
  731.        
  732.  
  733.                
  734.                
  735.                 course.setCurrentEnrollment(currentEnrollment);
  736.                
  737.                 for(int bc = 0; bc<courses.length; bc++) {
  738.                                     if(courses[bc] == null) {
  739.                                         courses[bc] = course;
  740.                                     }
  741.                                 }
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.         for(int ada = 0; ada < undergrads2.size(); ada++){
  758.             for(int eza = 0; eza < students.length; eza++){
  759.                 if(students[eza] == null) {
  760.                         students[eza] = undergrads2.get(ada);break;
  761.                     }
  762.                 }
  763.             }
  764.                
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.            
  774.         for(int ad = 0; ad < grads2.size(); ad++){
  775.             for(int ez = 0; ez < students.length; ez++){
  776.                 if(students[ez] == null) {
  777.                         students[ez] = grads2.get(ad);break;
  778.                     }
  779.                 }
  780.             }
  781.                
  782.  
  783.  
  784. }
  785.            
  786.        
  787.                            
  788.  
  789.                        
  790.                        
  791.  
  792.        
  793.  
  794.                        
  795.                
  796.                    
  797.                
  798.  
  799.        
  800.        
  801.        
  802.                
  803.            
  804.  
  805.         University ufl = new University(universityName, currentTerm, currentYear, students, instructors, courses);
  806.         return ufl;
  807.  
  808.  
  809.     }   catch (EmptyFileException e) {
  810.            
  811.             e.toString();
  812.        
  813.         } catch (FileNotFoundException x) {
  814.             x.printStackTrace();
  815.    
  816.        
  817.         }finally {
  818.             if (in != null)
  819.                
  820.                         in.close();
  821.         }
  822.            
  823.         return null;
  824.        
  825. }
  826.  
  827.  
  828.  
  829.    
  830.  
  831.  
  832.  
  833.                    
  834.  
  835.  
  836.  
  837.  
  838.  
  839.        
  840.  
  841.            
  842.  
  843.            
  844.  
  845.        
  846.  
  847.    
  848.  
  849.     // toString
  850.  
  851.     public String toString() {
  852.  
  853.         String str = "University Name: " + name;
  854.  
  855.         //str += "\nCurrent Semester: " + currentTerm + " " + year;
  856.  
  857.         str += "\nCurrent Term: " + currentTerm;
  858.  
  859.         str += "\nCurrent Year: " + year;
  860.  
  861.         str += "\nNumber of Students: " + students.length;
  862.  
  863.         str += "\nNumber of Instructors: " + instructors.length;
  864.  
  865.         str += "\nNumber of Courses: " + courses.length;
  866.  
  867.         return str;
  868.  
  869.     }
  870.  
  871. }
Add Comment
Please, Sign In to add comment