/*
*学生类,包括学生的基本信息
*/
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 strBirthday =" "; //出生年月
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(String sex)
{
strSex = sex;
}
public String getStudentSex()
{
return strSex;
}
public String getStudentBirthday(String birthday)
{
strBirthday = birthday;
}
public String getStudentSpeciality()
{
return strSpeciality;
}
public void setStudentSpeciality(String speciality)
{
strSpeciality = speciality;
}
public String getStudentAddress()
{
return strAddress;
}
public void setStudentAddress(String address)
{
strAddress = address;
}
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 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 strBirthday =" "; //出生年月
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(String sex)
{
strSex = sex;
}
public String getStudentSex()
{
return strSex;
}
public String getStudentBirthday(String birthday)
{
strBirthday = birthday;
}
public String getStudentSpeciality()
{
return strSpeciality;
}
public void setStudentSpeciality(String speciality)
{
strSpeciality = speciality;
}
public String getStudentAddress()
{
return strAddress;
}
public void setStudentAddress(String address)
{
strAddress = address;
}
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;
}
}
第42行 public void setStudentBirthday(String birthday)
照着书打都能打错,你还真猛!
*学生类,包括学生的基本信息
*/
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 strBirthday =" "; //出生年月
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 void setStudentSex(String sex)
{
strSex = sex;
}
public String getStudentSex()
{
return strSex;
}
public void setStudentBirthday(String birthday)
{
strBirthday = birthday;
}
public String getStudentSpeciality()
{
return strSpeciality;
}
public void setStudentSpeciality(String speciality)
{
strSpeciality = speciality;
}
public String getStudentAddress()
{
return strAddress;
}
public void setStudentAddress(String address)
{
strAddress = address;
}
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;
}
}
我改完的.你看看有什么不一样的?