package com.ctgu.test6_collection;
import java.util.HashSet;
import java.util.Set;
public class Student implements Comparable<Student>{
public String id;
public String name;
public Set<Course> courses;
public Student(String id,String name){
this.id = id;
this.name = name;
this.courses = new HashSet<Course>();
}
@Override
public String toString() {
return "Student [id=" + id + ", name=" + name + ", courses=" + courses + "]";
}
@Override
public int compareTo(Student stu) {
// return this.id.compareTo(stu.id);
return this.name.compareTo(stu.name);
}
}
网友评论