import java.io.*;
import java.util.*;

public class Driver {
	public static void main(String[] args) {
	
		Student s1 = new Student("Paul", 90);
		Student s2 = new Student("Gary", 88);
		Student s3 = new Student("Ray", 70);
		
		// Some test cases for getMax().
		
		// Test case 1: getMax() on a vector with only one element.
		// Expected result: Paul (s1).
		Vector v1 = new Vector();
		v1.addElement(s1);
		System.out.println("Test 1 - max: " + getMax(v1).getName());
		
		// Test case 2: getMax() on a three-element vector sorted in
		// increasing order.
		// Expected result: Paul (s1).
		Vector v2 = new Vector();
		v2.addElement(s1);
		v2.addElement(s2);
		v2.addElement(s3);
		System.out.println("Test 2 - max: " + getMax(v2).getName());
		
		// Test case 3: getMax() on a three-element vector sorted in
		// decreasing order.
		// Expected result: Paul (s1).
		Vector v3 = new Vector();
		v3.addElement(s3);
		v3.addElement(s2);
		v3.addElement(s1);
		System.out.println("Test 3 - max: " + getMax(v3).getName());
		
		// There are other cases that should be tested. Can you think
		// of any?
	}
	
	// Returns the student in 'v' whose mark is the highest.
	// Precondition: There must be at least one student in
	// the Vector 'v'.
	public static Student getMax(Vector v) {
		Student max = (Student)v.elementAt(0);
		int i = 1;
		while (i < v.size()) {
			Student s = (Student)v.elementAt(i);
			if (s.getMark() > max.getMark()) {
				max = s;
			}
			i = i + 1;
		}
		// Postcondition: max is the student whose mark
		// is the maximum out of all the students' marks.
		return max;
	}
}
