/** Student.java models a camp student.
 * @author Joel Adams, for Alice+Java.
 */

import java.util.Scanner;

public class Student implements Comparable<Student> {
	/** default constructor
	 *  Postcondition: myName and myScore are set to default values.
	 */
	public Student() {
		myName = "";
		myScore = 0;
	}
	
//	public Student(String name, int score) {
//		if (score < 0 || score > 100) {
//			throw new IllegalArgumentException("Student: bad score");
//		}
//		myName = name;
//		myScore = score;
//	}
	
	/** name accessor
	 * @return myName
	 */
	public String getName()  { return myName; }
	
	/** score accessor
	 * @return myScore
	 */
	public int getScore() { return myScore; }
	
	/** string conversion
	 * @return a string representation of myself
	 */
	public String toString() { return myName + "(" + myScore + ")"; }
	
	/** comparison (for Comparable interface)
	 * @param stu, a Student
	 * @return a negative value if myScore < stu's score
	 *         0 if myScore == obj's score
	 *         a positive value if myScore > stu's score
	 */
	public int compareTo(Student stu) {
		return myScore - stu.getScore();
	}
	
	/** read a Student value from a Scanner
	 * @param in, a Scanner
	 * Precondition: in contains two names and a score
	 * Postcondition: myName == the two names AND
	 *                myScore == the score.
	 */
	public void read(Scanner in) {
		String name = in.next() + " " + in.next();
		int score = in.nextInt();
		if (score < 0 || score > 100) {
			throw new IllegalArgumentException("read(): bad score");			
		}
		myScore = score;
		myName = name;
	}
	
	private String myName;
	private int myScore;
}
