Please help in Java:
Create a main method and use these input files to test that you are able to input the Undergraduates, put them into an ArrayList, print out the list. Repeat for Graduate, Faculty, Staff. Do it all in ONE main.
Then- Add a compareTo to each class (and any other code you need) so you can sort all your ArrayLists and print out the results. Your final output should be all the Undergraduates (sorted), all the Graduates (sorted), all the Faculty(sorted), and all the Staff (sorted).
To sort: Sort undergrads and grads according to ID. Sort Faculty according to Department and Staff according to Salary.
I have Lab10.java to keep main in but it is not completed, which is what im seeking help for.
I have Person.java ; Student.java ; Employee.java ; Undergraduate.java ; Graduate.java ; Faculty.java & Staff.java completed. Example:
Graduate.java
public class Graduate extends Student{ //add attributes : String degree and boolean thesis private String degree; private boolean thesis; //default value of boolean is false public Graduate(){ super(); degree=" "; } public Graduate(String initialDegree, String initialName, int initialStudentNumber){ super(initialName, initialStudentNumber); degree=initialDegree; } public boolean isThesis() { return thesis; } public void setThesis(boolean thesis) { this.thesis = thesis; } public String getDegree() { return degree; } public void setDegree(String degree) { this.degree = degree; } public void writeOutput(){ super.WriteOutput(); // print student details //now print extra details present for graduate System.out.println("Degree: "+ degree); System.out.println("Thesis Completed: "+ thesis); } public boolean equals(Graduate otherGraduate){ return this.degree == otherGraduate.degree; } }
Staff.java
public class Staff extends Employee { int payGrade; public Staff(){ super(); payGrade=0; } public Staff(String initialName, int payGrade){ //constructor call of Employee super(initialName); //extra attribute setting of Staff this.payGrade = payGrade; } public int getPayGrade() { return payGrade; } public void setPayGrade(int payGrade) { //you can also add checks here or wherever you set Pay Grade for valid value between 1 to 20 this.payGrade = payGrade; } }
Faculty.java
public class Faculty extends Employee { private String title; public Faculty(){ super(); title= " "; } public Faculty(String initialName, String initialTitle){ super(initialName); title=initialTitle; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public void Reset(String newName){ setName(newName); } public void WriteOutput(){ super.WriteOutput(); System.out.println("Title: "+title); } public boolean Equals(Faculty other){ return this.hasSameName(other)&&(this.title==other.title); } }