/*
********************************************************************************
*  Kelli Wiseth
*  kelli@alameda-tech-lab.com
*  CIS 255AX
*  Program name: Student.java
*  Program Description: An abstract data type that models information about a
*      student. 
*
*  Assignment #7
*  10 May 2005
********************************************************************************
*/

import java.text.DecimalFormat;

public class Student extends Object { 

   private String firstName;
   private String lastName;
   private String studentID;
   private double gpa;
   private DecimalFormat fmt;
  
   // The default constructor 
   public Student(){
   	
   }
   
   // A constructor that accepts values to initialize all fields of the student
   public Student(String lName, String fName, String id, double gradePtAvg) {
    lastName = lName;
    firstName = fName;
    studentID = id;
    setGPA(gradePtAvg);
   }
  /***************************************************************************
   * Getter methods for each of the fields
   **************************************************************************
   */
   
   public String getLastName() {
    return lastName;
  }

  public String getFirstName() {
    return firstName;
  }

  public String getStudentID() {
    return studentID;
  }

  public double getGPA() {
    return gpa;
  }

  /***************************************************************************
   * Setter methods for each of the fields
   **************************************************************************
   */

  public void setLastName(String lName) {
    lastName = lastName;
  }

  public void setFirstName(String fName) {
    firstName = firstName;
  }

  public void setStudentID(String id) {
    studentID = id;
  }
  
  // Need to add some validation logic to ensure GPA makes sense
  
  public void setGPA(double gradePtAvg) {
  	
    gpa = (gradePtAvg > 4.0 ? 4.0 : gradePtAvg);
  }

 
  // A toString() method that outputs the data in the appropriate format for the Display
  // function
  
   public String toString() {
  	 DecimalFormat twoDecimalPlaces = new DecimalFormat("0.0#");
     return  studentID.toString() + " " + lastName.toString() + ", " + firstName.toString() + " " +  twoDecimalPlaces.format(gpa);
   }
 
}//Student class (abstract data type)

