
/*
 * SOLUTION
 * 
 * - Write Javadoc for your class and run and test to ensure it is complete and correct.
 *
 * - Declare and define a class called "CSCStudent" which has 
 *   instance variables representing:
 *
 *    String student name
 *    int age 
 *    String gender
 *    String student number
 *    double program fees
 *    String comp sci minimum GPA requirement
 *    String gpa
 *    int total number of students enrolled
 * 
 * Note: For each variable, think about whether the variable should be static or not.
 * 
 * - Provide 3 constructors : NOTE: these are NOT method headers.  Please change 
 * depending on what type your variables are.
 * 
 * public CSCStudent()
 * public CSCStudent(name)
 * public CSCStudent(name, age, sex, studentNum, gpa) 
 *
 * Note: For each method, think about whether it is a procedure or function,
 * what its parameters should be, and whether it is Static or not.
 *
 * - Provide getter and setter methods for each of the instance variables
 * 
 * - Write an equals and toString method that seem appropriate.
 *
 * - add a method that you can use to calculate their percentile. 
 *   Use the following calculation: gpa / 4 * 100 (note: this is not the correct calculation, it is
 *   just simplified for our purposes)* 
 * 
 * - write method isEligible that determines if a student meets the GPA requirements for
 *   the computer science program
 * 
 * - write a method that returns the total number of students in the computer science department
 * 
 */

/**
 * The CSCStudent class represents a student in the Computer Science program.
 * */
public class CSCStudent {
  
  /** The student's full name. */
  private String name;  
  
  /** The students age.*/
  private int age; 
  
  /** The student's gender. */
  private String gender; 
  
  /** The student number. */
  private String studentNumber; 
  
  /** The fees required to register in the Computer Science program. */
  private static double programFees;  
  
  /** The total number of students in the Computer Science department. */
  private static int totalStudents; 
  
  // Note: The purpose of making the GPA's strings is for the students to use 
  // Double.parseInt in the calculatePercentile function.
  
  /** The minimum GPA required to register in the Computer Science program. */
  private static String reqGPA; 
  
  /** The student's GPA. */
  private String gpa;  
  
  /**
   * Constructs a default CSCStudent object.
   */
  public CSCStudent(){
    name = "";
    gender = "";
    studentNumber = "";
    gpa = "";
    // Increment the total number of students in the program by 1.
    totalStudents++;
  }  
  
  /**
   * Constructs a CSCStudent object with the given name.
   * @param name The name of the student.
   */
  public CSCStudent(String name){
    this.name = name;
    // Increment the total number of students in the program by 1.
    totalStudents++;
  }  
  
  /**
   * Constructs a CSCStudent object with the name, age, gender, student number 
   * and gpa.
   * @param name The name of the new student as a <code> String </code>.
   * @param age The age of the new student as an <code> int </code>.
   * @param gender The gender of the new student as a <code> String </code>.
   * @param sn The student number as a <code> String </code>.
   * @param gpa The student's gpa as a <code> String </code>.
   */
  public CSCStudent(String name, int age, String gender, String sn, String gpa){
    this.name = name;
    this.age = age;
    this.gender = gender;
    this.studentNumber = sn;
    this.gpa = gpa;
    // Increment the total number of students in the program by 1.
    totalStudents++;
  }
  
  /**
   * Sets the student's name to the given parameter. 
   * @param name The new name as a <code> String </code>.
   */ 
  public void setName(String name){
    this.name = name;
  }
  
  /**
   * Sets the student's age to the given parameter. 
   * @param age The new age as an <code> int </code>.
   */  
  public void setAge(int age){
    this.age = age;
  }
  
  /**
   * Sets the student's gender to the given parameter. 
   * @param gender The new gender as a <code> String </code>.
   */
  public void setGender(String gender){
    this.gender = gender;
  }
  
  /**
   * Sets the student number to the given parameter. 
   * @param sn The new student number as a <code> String </code>.
   */  
  public void setSN(String sn){
    this.studentNumber=sn;
  }
  
  /**
   * Gets the student's name. 
   * @return The student's name as a <code> String </code>.
   */
  public String getName(){
    return name;
  }
  
  /**
   * Gets the student's age. 
   * @return The student's age as an <code>int</code>.
   */
  
  public int getAge(){
    return age;
  }
  
  /**
   * Gets the student's gender. 
   * @return The student's gender as a <code> String </code>.
   */
  
  public String getGender(){
    return gender;
  }
  
  /**
   * Gets the student number. 
   * @return The student number as a <code> String </code>.
   */
  
  public String getStudentNumber(){
    return studentNumber;
  }
  
  /**
   * Gets the student's GPA. 
   * @return The student's GPA as a <code> String </code>.
   */
  
  public String getGPA(){
    return gpa;
  }
  
  /**
   * Gets the total number of students in the Computer Science program. 
   * @return The total number of enrolled students as an<code> int </code>.
   */
  public static int gettotalStudents(){
    return gpa;
  }
  /**
   * Sets the tuition fee for the Computer Science program to the given 
   * parameter. 
   * @param fee The program fees as a <code> double</code>.
   */
  public static void setProgramFee (double fee) {
    programFees = fee;
  }
  
  /**
   * Sets the minimum GPA requirement for being in the Computer Science program
   * to the given parameter. 
   * @param req The GPA requirement for the program as a <code> String </code>.
   */
  public static void setReqGPA (String req) {
    reqGPA = req;
  }
  
  /**
   * Checks whether the given student2 object is the same as this student. 
   * 
   * @param student2 The object with which you want to compare this one.
   * @return true if the two students have the same name and student number
   *               else false.
   */
  public boolean equals(Object student2) {
    
    // Ensure that the object being compared is of the same class
    // and that their name and student number is the same.
    // If an object of any other type but CSCStudent is passed in,
    // this method will return false.
    return student2 instanceof CSCStudent &&
      ((CSCStudent)student2).getName().equals(name) &&
      ((CSCStudent)student2).getStudentNumber().equals(studentNumber); 
  }
  
  /**
   * Returns a string representation of CSCStudent that looks like:
   * "Full Name : Student Number : age : gender : gpa"
   * 
   * @return a <code>String</code> representing this student.
   */
  public String toString(){
    return name + " : " + 
      studentNumber + " : " + 
      age + " : " +
      gender + " : " + 
      gpa;
  }
  
  /**
   * Checks whether this student meets the minimum GPA requirement for the 
   * Computer Science program. 
   * 
   * @return true if the students GPA is equal or higher than the required GPA,
   * false otherwise.
   */
  public boolean isEligible() {
    return Double.parseDouble(gpa)>=Double.parseDouble(reqGPA);
  }
  
  /**
   * Calculates and returns the percentage equivalent of this students GPA.
   * @return the percentage grade of this student as a <code> double </code>.
   */
  public double percentGrade() {
    return Double.parseDouble(gpa)/4.0 *100;
  }
}



