package fouth;
public class InterfaceTest {
public static void main(String[] args) {
Student1 astudent=new Student1("tom", "123456");
astudent.setAddress("beijing");
astudent.setSex("men");
System.out.println(astudent);
}
}
interface Person{
String getName();
String getSex();
String getBirthday();
String getAddress();
void setAddress(String strAddress);
}
class Student implements Person,Comparable{
private String strName="";
private String strSex="";
private String strNumber="";
private String strBirthday="";
private String strSpeciality="";
private String strAddress="";
public String getSex() {
return strSex;
}
public void setAddress(String string) {
// TODO Auto-generated method stub
}
public void setSex(String strSex) {
this.strSex = strSex;
}
public String getBirthday() {
return strBirthday;
}
public void setBirthday(String strBirthday) {
this.strBirthday = strBirthday;
}
public String getSpeciality() {
return strSpeciality;
}
public void setSpeciality(String strSpeciality) {
this.strSpeciality = strSpeciality;
}
public String getAddress() {
return strAddress;
}
public String getName() {
return strName;
}
public String getNumber() {
return strNumber;
}
public Student1(String strName, String strNumber) {
super();
this.strName = strName;
this.strNumber = strNumber;
}
public String toString(){
String information="学生姓名="+strName+",学号="+strNumber;
if(!strSex.equals("")){
information+=",性别="+strSex;
}
if(!strBirthday.equals("")){
information+=",出生年月="+strBirthday;
}
if(!strSpeciality.equals("")){
information+=",专业="+strSpeciality;
}
if(!strAddress.equals("")){
information+=",籍贯="+strAddress;
}
return information;
}
public void setAddress1(String strAddress) {
this.strAddress=strAddress;
int compareTo(Object otherObject) {
Student other=(Student)otherObject;
int otherNumber=Integer.parseInt(other.strNumber);
return 0;
}
}
}
//这是全部代码,谢谢了