Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help language java. Instructions: The only things you can import are the Scanner and the File. Any extra functionality besides the default (i.e. java.lang) is

Help language java.

Instructions:

  1. The only things you can import are the Scanner and the File. Any extra functionality besides the default (i.e. java.lang) is disallowed.
  2. You may not use any built-in functionality for copying an array, like System.arrayCopy(), Arrays.copyOf(), Object.clone(), Arrays.stream, etc. If you want to copy an array, you should do it manually (i.e. create a new array and transfer the data).

class College

An object of this class will represent a single college.

Fields:

  • int id : A unique id number

  • String name : A unique name

  • int numOfPositions : A positive number that denotes how many positions the college has available this year.

  • minSAT : The minimum SAT score that the college 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

Methods:

  • College(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 is admissible, it is added to the list of admitted students and returns true, otherwise it returns 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 college.

  • 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 college in the form of id: name, e.g. 312: Harvard University

  • equals(Object other) : Overrides the default method and compares this college to the other college. Don't forget the @Override annotation. It returns true if the two colleges have the same id and name.

  • you can add more as needed

class CollegeList

It stores multiple colleges instead of multiple students in a list that can grow/shrink via the provided methods.

Fields:

  • An array of College. You can pick any name you like. It stores all the current college values in an array that is exactly the right length (it should never have extra spots available).
  • you can add more as needed

Methods

  • CollegeList() : This constructor method initializes the internal array to size zero.

  • CollegeList(String filename) : This constructor method initializes the internal array by loading data from a file. The file will contain one line per college with id,name,available_positions,minimum_SAT as in the example below:

    309,Virginia Tech,7,1400 141,George Washington University,6,1200 273,University of Virginia,5,1500 165,James Madison University,4,1100 113,George Mason University,8,1300 
  • int size() : Returns how many items are currently in the list.

  • get(int index) : Returns the value at the provided index. Must throw a RuntimeException when the index is out of bounds.

  • void set(int index, College value) : Changes the value at the given index to the new value. Must throw a RuntimeException when the index is out of bounds.

  • indexOf(College 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).

  • indexOf(int collegeID) : It's an overloaded version of the previous method. It does the same operation but this one finds the college based on its id. Must return -1 when a university with that id is not found in the list.

  • void insert(Collegevalue) : It takes one parameter only because the index where the value is to be inserted, is not provided by the caller but it's inferred by the method itself. The insertion must occur in the index that will have the effect of preserving the list ordered (in ascending alphanumerical order based on the name of the college). The method throws a RuntimeException if the given value is null.

  • toString : Overrides the default method. Don't forget the @Override annotation. It represents a list a comma separated representations of colleges enclosed in curly braces. For example, if there were two colleges in the list, "George Mason University" and "University of Virginia", then we would return "{113: George Mason University, 273: University of Virginia}".

  • you can add more as needed

Please Help with these 2 classes. Comments are appreciated! :)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions