GaleShapley.java
//The following will apply the Gale Shapley algorithm to pair each employer to a student
The following will apply the Gale Shapley algorithm to pair each employer to a student
The following will apply the Gale Shapley algorithm to pair each employer to a student
void execute(int[] students, int[] employers, int[][] A, ArrayList<String> studentNames, ArrayList<String> employerNames, String filename, int listSize) throws Exception {
        while(!Sue.empty()){
            int employer = -1;
            int stu;
            int pEmployer;
            employer = Sue.pop();
            stu = PQArr.get(employer).poll().student;
            pEmployer = students[stu];
            if (students[stu]==-1){
                students[stu] = employer;
                employers[employer] = stu;
            }else if (A[stu][employer] < A[stu][pEmployer]){
                students[stu] = employer;
                employers[employer] = stu;
                employers[pEmployer] = -1;
                Sue.push(pEmployer);
            }else {
                Sue.push(employer);
            }
        }
        /********System prints for testing*********/
        String[] output = new String[listSize];
        for(int i = 0; i < listSize; i++){
            output[i] = "Match "+i+" : " + employerNames.get(i).toString() + " - " + studentNames.get(students[i]).toString();
            System.out.println(output[i]);
        }
        save(filename, output, listSize);
    }
void execute ( int [ ] students , int [ ] employers , int [ ] [ ] A , ArrayList < String > studentNames , ArrayList < String > employerNames , String filename , int listSize ) throws Exception { while ( ! Sue . empty ( ) ) { int employer = - 1 ; int stu ; int pEmployer ; employer = Sue . pop ( ) ; stu = PQArr . get ( employer ) . poll ( ) . student ; pEmployer = students [ stu ] ; if ( students [ stu ] == - 1 ) { students [ stu ] = employer ; employers [ employer ] = stu ; } else if ( A [ stu ] [ employer ] < A [ stu ] [ pEmployer ] ) { students [ stu ] = employer ; employers [ employer ] = stu ; employers [ pEmployer ] = - 1 ; Sue . push ( pEmployer ) ; } else { Sue . push ( employer ) ; } } /********System prints for testing*********/ String [ ] output = new String [ listSize ] ; for ( int i = 0 ; i < listSize ; i ++ ) { output [ i ] = "Match " + i + " : " + employerNames . get ( i ) . toString ( ) + " - " + studentNames . get ( students [ i ] ) . toString ( ) ; System . out . println ( output [ i ] ) ; } save ( filename , output , listSize ) ; }
The following will apply the Gale Shapley algorithm to pair each employer to a student
The following will apply the Gale Shapley algorithm to pair each employer to a student
//All variables declared and initialized //The following follows the pseudocode implementation provided // System.out.println(Arrays.toString(students)); // System.out.println(Arrays.toString(employers)); //The employers[] and students[] arrays are updated above and now their index values will be matched to the respective  //string values from the arrays declared in the initialize method. //The following will generate an array of the results but also print to console for the user //The save metod is called and the respective variables are passed