Class Student

java.lang.Object
  extended by Student

public class Student
extends java.lang.Object

Represents a student with a name and several test scores


Field Summary
static int MAX_SCORE
          The maximum score (100)
static int MIN_SCORE
          The minimum score (0)
 
Constructor Summary
Student()
          Default: name is "" and each of 3 scores is 0
Student(java.lang.String nm)
          Name is nm and each of 3 scores is 0
Student(java.lang.String nm, int n)
          Name is nm and each of n scores is 0
Student(java.lang.String nm, int[] t)
          Name is nm and the scores are taken from array t
Student(Student s)
          Builds a copy of a student
 
Method Summary
 int getAverage()
           
 int getHighScore()
           
 java.lang.String getName()
           
 int getScore(int i)
           
 void setName(java.lang.String nm)
          Changes the studentŐs name
 void setScore(int i, int score)
           
 java.lang.String toString()
           
 java.lang.String validateData()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_SCORE

public static int MIN_SCORE
The minimum score (0)


MAX_SCORE

public static int MAX_SCORE
The maximum score (100)

Constructor Detail

Student

public Student()
Default: name is "" and each of 3 scores is 0


Student

public Student(java.lang.String nm)
Name is nm and each of 3 scores is 0

Parameters:
nm - the name of the student

Student

public Student(java.lang.String nm,
               int n)
Name is nm and each of n scores is 0

Parameters:
nm - the name of the student
n - is the number of scores, each 0

Student

public Student(java.lang.String nm,
               int[] t)
Name is nm and the scores are taken from array t

Parameters:
nm - the name of the student
t - an array of test scores

Student

public Student(Student s)
Builds a copy of a student

Parameters:
s - the student to be copied
Method Detail

setName

public void setName(java.lang.String nm)
Changes the studentŐs name

Parameters:
nm - the new name

getName

public java.lang.String getName()
Returns:
the student's name

setScore

public void setScore(int i,
                     int score)
Parameters:
i - the ith
score - the ith score
Throws:
java.lang.IllegalArgumentException - if i < 1 or i > number of scores
java.lang.IllegalArgumentException - if score < MIN_SCORE or score > MAX_SCORE

getScore

public int getScore(int i)
Parameters:
i - the ith
Returns:
the student's ith score
Throws:
java.lang.IllegalArgumentException - if i < 1 or i > number of scores

getAverage

public int getAverage()
Returns:
the student's average score

getHighScore

public int getHighScore()
Returns:
the student's highest score

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
the student's string representation

validateData

public java.lang.String validateData()
Returns:
null if there are no errors or an appropriate error message