public int compareTo(StudentIO s)
{
int num = new Integer(this.sum).compareTo(new Integer (s.sum));
if (num==0)
return this.name.compareTo(s.name);
return num;
}
public String getName()
{
return name;
}
public int getSum()
{
return sum;
}
public int hashCode()
{
return name.hashCode()+sum*78;
}
public boolean equals(Object obj)
{
if(!(obj instanceof StudentIO))
throw new ClassCastException("类型不匹配");
StudentIO s =(StudentIO)obj;
class StudentInfoTool
{
public static Set<StudentIO> getStudents()throws IOException
{
BufferedReader bufr =
new BufferedReader(new InputStreamReader(System.in));
String line = null;
Set<StudentIO> stus = new TreeSet<StudentIO>();
while((line=bufr.readLine())!=null)
{
if("over".equals(line))
break;
String[] info = line.split(",");
StudentIO stu = new StudentIO (info[0],Integer.parseInt(info[1]),
Integer.parseInt(info[2]),Integer.parseInt(info[3]));
stus.add(stu);
}
bufr.close();
return stus;
}
public static void write2File(Set<StudentIO> stus)throws IOException
{
BufferedWriter bufw = new BufferedWriter(new FileWriter("stuinfo.txt"));
for(StudentIO stu : stus)
{
bufw.write(stu.toString()+"\t");
bufw.write(stu.getSum()+"");
bufw.newLine();
bufw.flush();
}
bufw.close();
}
}
public class StudentTest_IO
{
public static void main(String[] args) throws IOException
{