import java.util.Vector; //------------------------------------------------------------------------- /** * This class represents a rudimentary gradebook that contains a set * of student records. It is not very complete yet, but should serve * as an example. * * @author Stephen Edwards * @version Feb 22, 2005 */ public class Gradebook { //~ Instance/static variables ............................................. private Vector students; //~ Constructor ........................................................... // ---------------------------------------------------------- /** * Creates a new Gradebook object. The gradebook is initially empty. */ public Gradebook() { students = new Vector(); } //~ Methods ............................................................... // ---------------------------------------------------------- /** * Add another student record to this gradebook. * @param student the new student record to add */ public void addStudent( Student student ) { students.add( student ); } // ---------------------------------------------------------- /** * Look up a student record by name in this gradebook. * @param name the name of the student to find * @return the student record, if found, or null if no student record * with the given name is found */ public Student findStudent( String name ) { for ( int i = 0; i < students.size(); i++ ) { Student student = (Student)students.elementAt( i ); if ( ( name == null && student.name() == name ) || name.equals( student.name() ) ) { return student; } } return null; } }