-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent_holist.java
More file actions
43 lines (38 loc) · 1.1 KB
/
Student_holist.java
File metadata and controls
43 lines (38 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Student_holist.java: sample implementation for Student
// COS 445 HW1, Spring 2018
// Created by Andrew Wonnacott
import java.util.Arrays;
import java.util.List;
public class Student_holist implements Student {
private class School implements Comparable<School> {
public School(int i, double q) {
index = i;
quality = q;
}
private int index;
private double quality;
public int compareTo(School n) { // smaller pairs are higher quality
int ret = Double.compare(n.quality, quality);
return (ret == 0) ? (Integer.compare(index, n.index)) : ret;
}
}
public int[] getApplications(
int N,
double S,
double T,
double W,
double aptitude,
List<Double> schools,
List<Double> synergies) {
School[] preferences = new School[schools.size()];
for (int i = 0; i != synergies.size(); ++i) {
preferences[i] = new School(i, schools.get(i) + synergies.get(i));
}
Arrays.sort(preferences);
int[] ret = new int[10];
for (int i = 0; i != 10; ++i) {
ret[i] = preferences[i].index;
}
return ret;
}
}