//Student.java

package javadocsample;

/**
 * A simple class for a student with a name and a student number.
*/
public class Student
    extends Person
{
    private int studentNumber;

    /**
     * Creates a default student.
     */
    public Student()
    {
        super();
        studentNumber = 0;//Indicating no number yet
    }

    /**
     * Creates a student with the supplied name and student number.
     * @param initialName The name of the student.
     * @param initialStudentNumber The student's student number.
     */
    public Student
    (
        String initialName,
        int initialStudentNumber
    )
    {
        super(initialName);
        studentNumber = initialStudentNumber;
    }

    /**
     * Resets student name and number.
     * @param newName The new name to be given to the student.
     * @param newStudentNumber The student's new student number.
     */
    public void reset
    (
        String newName,
        int newStudentNumber
    )
    {
        setName(newName);
        studentNumber = newStudentNumber;
    }

    /**
     * Gets the student's student number.
     * @return The student number of the student.
     */
    public int getStudentNumber()
    {
        return studentNumber;
    }

    /**
     * Sets student number.
     * newStudentNumber The new student number to be given to the student.
    */
    public void setStudentNumber
    (
        int newStudentNumber
    )
    {
        studentNumber = newStudentNumber;
    }

    /**
     * Displays the name and student number of the student.
     * The name and student number appear on separate lines.
     */
    public void writeOutput()
    {
        System.out.println("Name: " + getName());
        System.out.println("Student Number: " + studentNumber);
    }

    /**
     * Tests if this student is the same as another student.
     * @param otherStudent the Student object being compared to the calling
     * object.
     * @return true only if calling object and otherStudent have the same
     * name and the same student number.
     */
    public boolean equals
    (
        Student otherStudent
    )
    {
        return (this.sameName(otherStudent) &&
            (this.studentNumber == otherStudent.studentNumber));
    }

    /**
     * Returns a string representation of the student. It consists of the
     * student's name and student number combined into a single string.
     */
    public String toString()
    {
        return ("Name: " + getName() + "\nStudent number: " + studentNumber);
    }
}

