
public class Student implements Comparable {
	String name;
	String uniID;
	double exam, lt1, lt2, lt3, ass;
	
	static final double assignmentPercent = 0.3; 
	
	public Student(String n, String uniID, double exam, double lt1,
			double lt2, double lt3, double ass) {
		super();
		name = n;
		this.uniID = uniID;
		this.exam = exam;
		this.lt1 = lt1;
		this.lt2 = lt2;
		this.lt3 = lt3;
		this.ass = ass;
	}
	
	public int mark() {
	    return (int) Math.round(ass*assignmentPercent + Math.max(lt1,exam)*0.2/3.0 + 
	    		Math.max(lt2,exam)*0.2/3.0 + Math.max(lt3,exam)*0.2/3.0 + exam * 0.5); 	
	}
	
	
	public String grade(){
		int mark = mark();
		if (mark >= 80) {
			return "HD";
		} else if (mark >= 70) {
			return "D";
		} else if  (mark >= 60) {
			return "C";
		} else if  (mark >= 50) {
			return "P";
		} else {
			return "N";
		}
	}
	
	
	public String showReport() {
		return name + " " + uniID + " " + mark() + " " + grade();
	}
	
	static public Student parseStudent(String line) {
	    String str[] = line.split(":");
		return new Student(str[0], str[1], Double.parseDouble(str[2]),
				Double.parseDouble(str[3]),Double.parseDouble(str[4]),
				Double.parseDouble(str[5]),Double.parseDouble(str[6]));
	}

	@Override
	public int compareTo(Object o) {
		// TODO Auto-generated method stub
		
		Student other = (Student) o;
		/*if (other.mark() == this.mark()) {
			return 0;
		} else if (other.mark() < this.mark()) {
			return 1;
		} else {
		    return -1;
		}*/
		return - this.name.compareTo(other.name);
	}
	

}

