/*
*学生类,包括学生类的基本信息
*/
public class StudentTest{
public static void main(String[] args)
{
Student tom=new Student("Tom","20020410");
tom.setStudentSex("man");
tom.setStudentAddress("America");
System.out.println(tom.toString());
}
}
class Student{
private String strName=";
private String strNumber="";
private String strSex="";
private String strSpeciality="";
private String strAddress="";
public Student(String name,String number){
strName=name;
strNumber=number;
}
public String getStudentName(){
return strName;
}
public String getStudentNumber(){
return strNumber;
}
public String getStudentSex(){
return strStudentSex;
}
public String setStudentSex(String sex)
{
strSex=sex;
}
public String getStudentBirthday(){
return strBirthday;
}
public void setStudentBirthday(String birthday){
strBirthday=birthday;
}
public String getStudentSpeciality()
{
return strSpeciality;
}
public void setStudentSpeciality(){
strSpeciality=speciality;
}
public String getStudentAddress(){
return strAddress;
}
public void setStudentAddress(String address){
strAddress=address;
}
public String toString(){
String information ="student name="+strName+",student number ="+strNumber;
if(!strSex.equals(""))
information+=",sex="+strSex;
if(!strBirthday.equals(""))
information+=",birthday ="+strBirthday;
if(!strAddress.equals(""))
information+=",address="+strAddress;
return information;
}
}
}