package test;
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.TreeSet;
public class IOTest {
public static void main(String[] args) throws IOException {
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
TreeSet<Student> list=new TreeSet<Student>();
while(true)
{
String line=bf.readLine();
System.out.println("Client: "+line);
if("quit".equals(line))
break;
String[] wr=line.split(" ");
Student st=new Student(wr[0],Integer.parseInt(wr[1]),Integer.parseInt(wr[2]),Integer.parseInt(wr[3]));
list.add(st);
}
OutputStreamWriter osw=new OutputStreamWriter(new FileOutputStream("E://fuckchenyufei.txt",true));
int i=1;
for(Student s:list)
{
System.out.println(s.toString());
osw.write(i+". "+s.toString()+"\r\n");
i++;
}
osw.flush();
osw.close();
}
}
class Student implements Comparable<Student>{
private String name;
private int math;
private int chinese;
private int english;
private int sum;
public Student()
{
}
public Student(String name,int math,int chinese,int english)
{
this.name = name;
this.math = math;
this.chinese = chinese;
this.english = english;
this.sum = chinese+english+math;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getMath() {
return math;
}
public void setMath(int math) {
this.math = math;
}
public int getChinese() {
return chinese;
}
public void setChinese(int chinese) {
this.chinese = chinese;
}
public int getEnglish() {
return english;
}
public void setEnglish(int english) {
this.english = english;
}
public int getSum() {
return sum;
}
public void setSum() {
this.sum = this.chinese+this.english+this.math;
}
@Override
public String toString() {
return "Student [name=" + name + ", math=" + math + ", chinese="
+ chinese + ", english=" + english + ", sum=" + sum + "]";
}
@Override
public int compareTo(Student other) {
if(this.sum>other.sum)
return -1;
else if(this.sum<other.sum)
return 1;
else
return 0;
}
}