Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

-readFile(): ArrayList«Student» IreadonCampusStudentlpln: Scanner): I I run): vo

ID: 667633 • Letter: #

Question

-readFile(): ArrayList«Student» IreadonCampusStudentlpln: Scanner): I I run): void mCredits: int -mFname: String mld: String mLname: String arable compareTolpStudent: Student): int +Studentlpld:String. pFname: String. pLname: String): «ctor* +calcTuitlono; vod +compareTolpStudent: Student): int soverride» +getCredits(): int +getFirstName(): String +getld): string +getLastNamel: String +getTuititionll: double +setCredits(pCredits: int): void +setFname(pFname: Stringl: void +setld(pld: String): void +setLname pLname: String): void #setTuitionDTuition: double): void mTechFee: boolean mResident: boolean ramFee: double +OnlineStudentipld String, pFname: String. pLname: String): "ctorsProgram +calcTuition): void overrides +OnCampusStudentipld-String, pFname: String, pLname: String): ctors +caleTuition(): void override» +getProgramFee): double +getResidency: boolean +getTechFee(): boolean +setT TechFee: boole -+setProgramFee(pProgramFee: double): void +setResidency pResident: boolean): void

Explanation / Answer

/*Create a separate class abstract class Student and implement the subclasses of Studnet class and override the method calcTuition(); in subclasses of Student class. */


/*Defintion of abstract student class that implements the Comparable interface <Student> type.
*The class contains the methods deftions for instance variables.
*and overrides the compareTo method that compares the id's of Student class.
* */
//Student.java
public abstract class Student implements Comparable<Student>
{

   private int mCrdits;
   private String mFname;
   private String mLname;
   private int mId;
   private double mTuition;

   //constructor of Student class
   public Student(String pFname, String pLname)
   {
       mFname=pFname;
       mLname=pLname;
   }

   //Implement this method in the subclass
   //of student class
   public abstract void calcTuition();


   //Set credits of student
   public void setCredits(int pCredits)
   {
       mCrdits=pCredits;
   }

   //Returns the credits of student
   public int getCredits()
   {
       return mCrdits;
   }

   //Set first name
   public void setFname(String pFname)
   {
       mFname=pFname;
   }

   //Returns first name
   public String getFirstName()
   {
       return mFname;
   }

   //Set id
   public void setid(int pId)
   {
       mId=pId;
   }

   //Retunrns id
   public int getid()
   {
       return mId;
   }

   //Set last name
   public void setLname(String pLname)
   {
       mLname=pLname;
   }

   //Returns last name
   public String getLastName()
   {
       return mLname;
   }

   //Returns the tuition fee
   public void setTuition(double pTuition)
   {
       mTuition=pTuition;
   }

   //Returns the tuition fee
   public double getTuition()
   {
       return mTuition;
   }


   /*Override the method compareTo that takes the Student object and
   *compares the getid of the object and return 0 if the both id's are
   *equal.
   *returns -1 if the getid is less than pStudnet id
   *returns 1 if the getid is greater than pStudnet id
   * */
   @Override
   public int compareTo(Student pStudnet)
   {      
       if(getid()<pStudnet.getid())
           return -1;
       else if(getid()>pStudnet.getid())
           return 1;
       else
           return 0;
   }

   }

Note : Since rest of the code for the above is with you, add this Student.java class to the above project and make necessary changes.

Hope this helps you.