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

Please help???? /** * The Student class stores the grade information for one Stu

ID: 640313 • Letter: P

Question

Please help????

/**
* The Student class stores the grade information for one Student.
*/
public class Student implements Comparable {

    // Declare the instance variables.
    private ArrayList mExamList;
    private String mFirstName;
    private ArrayList mHomeworkList;
    private String mLastName;

    /**
     * Student()
     *
     * PSEUDOCODE: Save pFirstName and pLastName. Create mExamList Create
     * mHomeworkList
     */
    public Student(String pFirstName, String pLastName) {
       

    }

    /**
     * addExam()
     *
     * PSEUDOCODE: Call add(pScore) on getExamList() to add a new exam score to
     * the list of exam scores.
     */
    ???

    /**
     * addHomework()
     *
     * PSEUDOCODE:
     * Call add(pScore) on getHomeworkList() to add a new homework score to the list of homework scores.
     */
    ???

    /**
     * compareTo()
     *
     * PSEUDOCODE:
     * Return: -1 if the last name of this Student is < the last name of pStudent
     * Return: 0 if the last name of this Student is = the last name of pStudent
     * Return: 1 if the last name of this Student is > the last name of pStudent
     * Hint: the last names are Strings.
     */
    ???

    /**
     * getExam()
     *
     * Accessor method to retreive an exam score from the list of exams.
     */
    public int getExam(int pNum) {
        return getExamList().get(pNum);
    }

    /**
     * getExamList()
     *
     * Accessor method for mExamList.
     */
    protected ArrayList getExamList() {
        return mExamList;
    }

    /**
     * getFirstName()
     *
     * Accessor method for mFirstName.
     */
    public String getFirstName() {
        return mFirstName;
    }

    /**
     * getHomework()
     *
     * Accessor method to retrieve a homework score from the list of homeworks.
     */
    public int getHomework(int pNum) {
        return getHomeworkList().get(pNum);
    }

    /**
     * getHomeworkList()
     *
     * Accessor method for mHomeworkList.
     */
    protected ArrayList getHomeworkList() {
        return mHomeworkList;
    }

    /**
     * getLastname()
     *
     * Accessor method for mLastName.
     */
    public String getLastName() {
        return mLastName;
    }

    /**
     * setExam()
     *
     * Mutator method to store an exam score into the list of exam scores.
     */
    public void setExam(int pNum, int pScore) {
        getExamList().set(pNum, pScore);
    }

    /**
     * setExamList()
     *
     * Mutator method for mExamList.
     */
    protected void setExamList(ArrayList pExamList) {
        mExamList = pExamList;
    }

    /**
     * setFirstName()
     *
     * Mutator method for mFirstName.
     */
    public void setFirstName(String pFirstName) {
        mFirstName = pFirstName;
    }

    /**
     * setHomework()
     *
     * Mutator method to store a homework score into the list of homework
     * scores.
     */
    public void setHomework(int pNum, int pScore) {
        getHomeworkList().set(pNum, pScore);
    }

    /**
     * setHomeworkList()
     *
     * Mutator method for mHomeworkList.
     */
    protected void setHomeworkList(ArrayList pHomeworkList) {
        mHomeworkList = pHomeworkList;
    }

    /**
     * setLastname()
     *
     * Mutator method for mLastName.
     */
    public void setLastName(String pLastName) {
        mLastName = pLastName;
    }

    /**
     * toString()
     *
     * Returns a String representation of this Student. The format of the
     * returned string shall be such that the Student information can be printed
     * to the output file, i.e:
     *
     * lastname firstname hw1 hw2 hw3 hw4 exam1 exam2
     */

???
}

Explanation / Answer

import java.util.ArrayList; public class Student implements Comparable { // Declare the instance variables. private String mFirstName; private String mLastName; private ArrayList mExamList; private ArrayList mHomeworkList; //Student constructor Student(String pFirstname, String pLastName) { ArrayList pExamList = new ArrayList(); ArrayList mHomeworkList = new ArrayList(); setExamList(pExamList); setHomeworkList(mHomeworkList); setFirstName(pFirstname); setLastName(pLastName); } //Add an exam public void addExam(int pScore) { getExamList().add(pScore); } //Add homework public void addHomework(int pScore) { getHomeworkList().add(pScore); } //CompareTo method @Override public int compareTo(Student pStudent) { int compareLastName = this.getLastName().compareTo(pStudent.getLastName()); int returnValue = 0; if (compareLastName == 0) returnValue = 0; else if (compareLastName < 0) returnValue = -1; else returnValue = 1; return returnValue; } public int getExam(int pNum) { return getExamList().get(pNum); } protected ArrayList getExamList() { return mExamList; } protected void setExamList(ArrayList pExamList) { mExamList = pExamList; } public String getFirstName() { return mFirstName; } public void setFirstName(String pFirstName) { mFirstName = pFirstName; } public int getHomework(int pNum) { return getHomeworkList().get(pNum); } protected ArrayList getHomeworkList() { return mHomeworkList; } protected void setHomeworkList(ArrayList pHomeworkList) { mHomeworkList = pHomeworkList; } public String getLastName() { return mLastName; } public void setLastName(String pLastName) { mLastName = pLastName; } public void setExam(int pNum, int pScore) { getExamList().set(pNum, pScore); } public void setHomework(int pNum, int pScore) { getHomeworkList().set(pNum, pScore); } //Returns a String version of the student information @Override public String toString() { return this.getLastName() + " " + this.getFirstName() + " " + this.getHomework(0) + " " + this.getHomework(1) + " " + this.getHomework(2) + " " + this.getHomework(3) + " " + this.getExam(0) + " " + this.getExam(1); } }