学生类,包括学生的基本信息

CEO8888 2007-09-17 05:12:42
/*
*学生类,包括学生的基本信息
*/
public class StudentTest3
{

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 static void main(String[] args)
{
Student aStudent = new Student("沙和尚", "19990000");
aStudent.setStudentAddress("通天河");
System.out.println(aStudent.toString());
}

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 String getStudentBirthday()
{
return strBirthday;
}

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;
}
}
...全文
499 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
will125love 2007-09-18
  • 打赏
  • 举报
回复
呵呵,jf
mailtzy1 2007-09-18
  • 打赏
  • 举报
回复
这是做什么?
amazeur 2007-09-18
  • 打赏
  • 举报
回复
有问题吗?
约翰羊 2007-09-18
  • 打赏
  • 举报
回复
接分
up
ming4098 2007-09-18
  • 打赏
  • 举报
回复
:)
jxzhoumin 2007-09-18
  • 打赏
  • 举报
回复
有什么问题吗?
wuyi8808 2007-09-18
  • 打赏
  • 举报
回复
jf
livan1038 2007-09-18
  • 打赏
  • 举报
回复
樓主好有意思
接分
  • 打赏
  • 举报
回复
mailtzy1(转角处遇到猪)

有意思的签名~~
CEO8888 2007-09-17
  • 打赏
  • 举报
回复
怎么网站里面的资源都是下不了的
真是郁闷~~~~~~~~~~~
apple_yu 2007-09-17
  • 打赏
  • 举报
回复
SF,接分~

23,404

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧