4 CLASS STUDENTLIST The purpose of this class is to create a simplistic list- like structure to allow us to group Student values together. We will use an internal array of objects to provide functionality such as adding, removing. reading, and writing values into the sequence of Student objects. Check slides 47-51 in this lecture presentation for an overview of how memory works with arrays of objects. 4.1 fields An array of Student. You can pick any name you like. It stores all the current student values in an array that is exactly the right length (it should never have extra spots available). When implementing methods below, we will often be creating a new array of a different length and replacing the values of this variable because arrays cannot change length. you can add more as needed 4.2 methods StudentList(): This constructor method initializes the internal array to size zero. StudentList(String filename) This constructor method initializes the internal array by loading data from a file. The file will contain one line per student with id, name, SAT as in the example below: 1054, Charles, 1373 1042, Joseph, 1089 1049, Thomas Jefferson, 1394 1139, Edward, 1031 Student is cony. This is not constructor This initializes the internal array to size zero. StudentList(String filename) constructor method initializes the internal array by loading data from a file. The file will contain one line per student with id, name, SAT as in the example below: 1054, Charles, 1373 1042, Joseph, 1089 1049, Thomas Jefferson, 1394 1139, Edward, 1031 Studentlist copy(): This is not a constructor method itself; it does create a different StudentList object (with no aliases to itself) and returns this new copy. int size(): Returns how many items are currently in the list. .get(int index) : Returns the value at the provided index. Must throw RuntimeException when the index is out of bounds. This can be done with the following statement in Java: throw RuntimeException() a new void set(int index, Student value): Changes the value at the given index to the new value. Must throw a RuntimeException when the index is out of bounds. indexOf(Student value) : Finds the given value and returns that value's index in the list. Must return -1 when the value is not found (do not throw an exception). void add (Student value) : Adds the value to the end of the internal array. Since arrays can't change length, you must create a new array of the exact new required size, copy values over, and place the given value at the end. Must throw a RuntimeExcention if the given value is throw a RuntimeException if the given value is null. , void insert(int index, Student value): Has the effect of inserting this value in the list so that value is the new value at index, and any values previously at that location or later have all been pushed to the right by one. Must throw a RuntimeException if the given value is null Must throw a RuntimeException if the given index is out of bounds: It may be any index of the current array or equal to one larger than the last valid index, but no larger. void remove(Student value) : Finds and removes the value from the list. All values that were after it will be shifted one spot towards the beginning of the list. Must throw a RuntimeException when the given value does not exist in the list. getHighestScoreStudent : Returns the student that has the highest SAT score. Must throw a RuntimeException when there are no students admitted toString: Overrides the default method. Don't forget the @Override annotation. It represents a list a comma separated representations of Students enclosed in curly braces. For example, if there were three students in the list "1234: Donald Knuth", "99: John von Neumann", and "567: Alan Turing". then we would return "{1234: Donald Knuth, 99: John von Neumann, 567: Alan Turing)". you can add more as needed 4.3 manual grading criteria The internal array is replaced by a new array whose size is always exactly one spot longer or shorter than before. (Not for credit, but think, is there a better MOMCI index is out of bounds: It may be any index of the current array or equal to one larger than the last valid index, but no larger. void remove (Student value) : Finds and removes the value from the list. All values that were after it will be shifted one spot towards the beginning of the list. Must throw a RuntimeException when the given value does not exist in the list. getHighestScoreStudent : Returns the student that has the highest SAT score. Must throw a RuntimeException when there are no students admitted. .toString: Overrides the default method. Don't forget the @Override annotation. It represents a list a comma separated representations of Students enclosed in curly braces. For example, if there were three students in the list "1234: Donald Knuth", "99: John von Neumann", and "567: Alan Turing", then we would return "{1234: Donald Knuth, 99: John von Neumann, 567: Alan Turing)". you can add more as needed 4.3 manual grading criteria The internal array is replaced by a new array whose size is always exactly one spot longer or shorter than before. (Not for credit, but think, is there a better approach?) Optimal reuse of other methods and classes. You must not rewrite any code if you can get the result you want by calling another method. Correct choices for the visibility, the parameters and the return types. Proper documentation of fields and methods. preferably in javadoc style. 5 CLASS UNIVERSITY An object of this class will represent a single university. 5.1 fields int id : A unique id number String name : A unique name int numOfPositions : A positive number that denotes how many positions the university has available this year. minsAt : The minimum SAT score that the university will accept. Note though that during the matching process we can disable that and let the matching process complete as if no minimum is set. a Studentlist that will be used to store the admitted students. You can use any name you like. you can add more as needed 5.2 methods University(id, name, numOfPositions, minSAT) : A constructor that initializes the above fields. getid, getName, getNumOfPositions, getMinSAT : Getter methods void activateMinSAT (boolean value): Activates or deactivates the use of the SAT threshold during the matching process. It will be called before the matching process begins. boolean admit(Student value): Decides whether to admit a student or not if the student proces be called before the matching process begins. boolean admit(Student value) : Decides whether to admit a student or not. If the student is admissible, it is added to the list of admitted students and returns true, otherwise it retums false. .getAdmittedStudents Returns the StudentList of the admitted students. It can be called at any time, even during the matching process. It assumes that the caller will not modify the returned list but wants it only for inspection lastAdmittedStudentSAT : Returns the lowest SAT score among the students that were admitted to the university. void resetAdmissions : Clears the internal storage of the admitted students and frees any memory that was previously allocated for it. It's useful if we want to rerun the matching process with different parameters (e.g. activate/deactivate the min SAT score). .toString : Overrides the default method. Don't forget the @Override annotation. It represents a university in the form of id: name, e.g. 113: George Mason University equals(object other): Overrides the default method and compares this University to the other university. Don't forget the @Override annotation. It returns true if the two universities have the same id and name. you can add more as needed 5.3 manual grading criteria Correct choices for the visibility, the parameters and the return types. Proper declaration of additional fields/methods. you can add more as needed 3.2 methods Student(id, name, SAT): A constructor that initializes the above fields. .getId, getName, getSAT : Getter methods copy: Not a c constructor, but creates and retums a non-alias copy of this object. Useful for sharing the object without allowing modification toString: Overrides the default method. Don't forget the @Override annotation. It represents a student in the form of id: name, e.g. 1234: Donald Knuth .equals(Object other) : Overrides the default method and compares this Student to the other student. Don't forget the @Override annotation. It returns true if the two students have the same id and name. Hint: You can start your method with the following code to check if the other object has the proper type, and then, don't forget to cast the other object before you use it. if ( ! ( other instanceof Student) return false; } you can add more as needed 3.3 manual grading criteria Correct choices for the visibility, the parameters and the return types. Proper documentation of fields and methods, preferably in javadoc style. 3 CLASS STUDENT An object of this class will represent a single student. 3.1 fields int id : A unique id number String name : A non unique name. It can be first last or just first or any other string. int SAT : A numeric value between 0 and 1600. you can add more as needed 3.2 methods Student (id, name, SAT): A constructor that initializes the above fields. .getId, getName, getSAT : Getter methods copy : Not a constructor, but creates and retums a non-alias copy of this object. Useful for sharing the object without allowing modification. toString : Overrides the default method. Don't forget the @Override annotation. It represents a student in the form of id: name, e.g. 1234: Donald Knuth .equals(object other): Overrides the default method and compares this Student to the other student. Don't forget the @Override annotation. It returns true if the two students have the same id and name. Hint: You can start your method with the following code to check if the other object has the proper type, and then, don't forget to cast the other object before you use it. if (the instanceof Student) 4 CLASS STUDENTLIST The purpose of this class is to create a simplistic list- like structure to allow us to group Student values together. We will use an internal array of objects to provide functionality such as adding, removing. reading, and writing values into the sequence of Student objects. Check slides 47-51 in this lecture presentation for an overview of how memory works with arrays of objects. 4.1 fields An array of Student. You can pick any name you like. It stores all the current student values in an array that is exactly the right length (it should never have extra spots available). When implementing methods below, we will often be creating a new array of a different length and replacing the values of this variable because arrays cannot change length. you can add more as needed 4.2 methods StudentList(): This constructor method initializes the internal array to size zero. StudentList(String filename) This constructor method initializes the internal array by loading data from a file. The file will contain one line per student with id, name, SAT as in the example below: 1054, Charles, 1373 1042, Joseph, 1089 1049, Thomas Jefferson, 1394 1139, Edward, 1031 Student is cony. This is not constructor This initializes the internal array to size zero. StudentList(String filename) constructor method initializes the internal array by loading data from a file. The file will contain one line per student with id, name, SAT as in the example below: 1054, Charles, 1373 1042, Joseph, 1089 1049, Thomas Jefferson, 1394 1139, Edward, 1031 Studentlist copy(): This is not a constructor method itself; it does create a different StudentList object (with no aliases to itself) and returns this new copy. int size(): Returns how many items are currently in the list. .get(int index) : Returns the value at the provided index. Must throw RuntimeException when the index is out of bounds. This can be done with the following statement in Java: throw RuntimeException() a new void set(int index, Student value): Changes the value at the given index to the new value. Must throw a RuntimeException when the index is out of bounds. indexOf(Student value) : Finds the given value and returns that value's index in the list. Must return -1 when the value is not found (do not throw an exception). void add (Student value) : Adds the value to the end of the internal array. Since arrays can't change length, you must create a new array of the exact new required size, copy values over, and place the given value at the end. Must throw a RuntimeExcention if the given value is throw a RuntimeException if the given value is null. , void insert(int index, Student value): Has the effect of inserting this value in the list so that value is the new value at index, and any values previously at that location or later have all been pushed to the right by one. Must throw a RuntimeException if the given value is null Must throw a RuntimeException if the given index is out of bounds: It may be any index of the current array or equal to one larger than the last valid index, but no larger. void remove(Student value) : Finds and removes the value from the list. All values that were after it will be shifted one spot towards the beginning of the list. Must throw a RuntimeException when the given value does not exist in the list. getHighestScoreStudent : Returns the student that has the highest SAT score. Must throw a RuntimeException when there are no students admitted toString: Overrides the default method. Don't forget the @Override annotation. It represents a list a comma separated representations of Students enclosed in curly braces. For example, if there were three students in the list "1234: Donald Knuth", "99: John von Neumann", and "567: Alan Turing". then we would return "{1234: Donald Knuth, 99: John von Neumann, 567: Alan Turing)". you can add more as needed 4.3 manual grading criteria The internal array is replaced by a new array whose size is always exactly one spot longer or shorter than before. (Not for credit, but think, is there a better MOMCI index is out of bounds: It may be any index of the current array or equal to one larger than the last valid index, but no larger. void remove (Student value) : Finds and removes the value from the list. All values that were after it will be shifted one spot towards the beginning of the list. Must throw a RuntimeException when the given value does not exist in the list. getHighestScoreStudent : Returns the student that has the highest SAT score. Must throw a RuntimeException when there are no students admitted. .toString: Overrides the default method. Don't forget the @Override annotation. It represents a list a comma separated representations of Students enclosed in curly braces. For example, if there were three students in the list "1234: Donald Knuth", "99: John von Neumann", and "567: Alan Turing", then we would return "{1234: Donald Knuth, 99: John von Neumann, 567: Alan Turing)". you can add more as needed 4.3 manual grading criteria The internal array is replaced by a new array whose size is always exactly one spot longer or shorter than before. (Not for credit, but think, is there a better approach?) Optimal reuse of other methods and classes. You must not rewrite any code if you can get the result you want by calling another method. Correct choices for the visibility, the parameters and the return types. Proper documentation of fields and methods. preferably in javadoc style. 5 CLASS UNIVERSITY An object of this class will represent a single university. 5.1 fields int id : A unique id number String name : A unique name int numOfPositions : A positive number that denotes how many positions the university has available this year. minsAt : The minimum SAT score that the university will accept. Note though that during the matching process we can disable that and let the matching process complete as if no minimum is set. a Studentlist that will be used to store the admitted students. You can use any name you like. you can add more as needed 5.2 methods University(id, name, numOfPositions, minSAT) : A constructor that initializes the above fields. getid, getName, getNumOfPositions, getMinSAT : Getter methods void activateMinSAT (boolean value): Activates or deactivates the use of the SAT threshold during the matching process. It will be called before the matching process begins. boolean admit(Student value): Decides whether to admit a student or not if the student proces be called before the matching process begins. boolean admit(Student value) : Decides whether to admit a student or not. If the student is admissible, it is added to the list of admitted students and returns true, otherwise it retums false. .getAdmittedStudents Returns the StudentList of the admitted students. It can be called at any time, even during the matching process. It assumes that the caller will not modify the returned list but wants it only for inspection lastAdmittedStudentSAT : Returns the lowest SAT score among the students that were admitted to the university. void resetAdmissions : Clears the internal storage of the admitted students and frees any memory that was previously allocated for it. It's useful if we want to rerun the matching process with different parameters (e.g. activate/deactivate the min SAT score). .toString : Overrides the default method. Don't forget the @Override annotation. It represents a university in the form of id: name, e.g. 113: George Mason University equals(object other): Overrides the default method and compares this University to the other university. Don't forget the @Override annotation. It returns true if the two universities have the same id and name. you can add more as needed 5.3 manual grading criteria Correct choices for the visibility, the parameters and the return types. Proper declaration of additional fields/methods. you can add more as needed 3.2 methods Student(id, name, SAT): A constructor that initializes the above fields. .getId, getName, getSAT : Getter methods copy: Not a c constructor, but creates and retums a non-alias copy of this object. Useful for sharing the object without allowing modification toString: Overrides the default method. Don't forget the @Override annotation. It represents a student in the form of id: name, e.g. 1234: Donald Knuth .equals(Object other) : Overrides the default method and compares this Student to the other student. Don't forget the @Override annotation. It returns true if the two students have the same id and name. Hint: You can start your method with the following code to check if the other object has the proper type, and then, don't forget to cast the other object before you use it. if ( ! ( other instanceof Student) return false; } you can add more as needed 3.3 manual grading criteria Correct choices for the visibility, the parameters and the return types. Proper documentation of fields and methods, preferably in javadoc style. 3 CLASS STUDENT An object of this class will represent a single student. 3.1 fields int id : A unique id number String name : A non unique name. It can be first last or just first or any other string. int SAT : A numeric value between 0 and 1600. you can add more as needed 3.2 methods Student (id, name, SAT): A constructor that initializes the above fields. .getId, getName, getSAT : Getter methods copy : Not a constructor, but creates and retums a non-alias copy of this object. Useful for sharing the object without allowing modification. toString : Overrides the default method. Don't forget the @Override annotation. It represents a student in the form of id: name, e.g. 1234: Donald Knuth .equals(object other): Overrides the default method and compares this Student to the other student. Don't forget the @Override annotation. It returns true if the two students have the same id and name. Hint: You can start your method with the following code to check if the other object has the proper type, and then, don't forget to cast the other object before you use it. if (the instanceof Student)