數(shù)據(jù)加載中……
          StudentTest3.java
          public class StudentTest3{
          public static void main(String[] args){
          Student tom=new Student("Tom","20020410");
          tom.setStudentSex("man");
          tom.setSutdentAddress("America");
          System.out.println(tom.toString());
          }
          }
          class Student{
          private String strName="";
          private String strNumber="";
          private String sexSex="";
          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 void setStudentSex(String sex){
          strSex=sex;
          }
          public  String getStudentSex(){
          return strSex;
          }
          public String getStudentBirthday(){
          return strBirthday;
          }
          public void setStudentSpciality(String speciality){
          strSpeciality=speciality;
          }
          public String getStudentAddress(){
          return strAddress;
          }
          public void setStudentAddress(String address) {
          strAddress=address;
          }

          public String toString(){
          String information="學(xué)生姓名="+strName+",學(xué)號="+strNumber;
          if(!strSex.equals("")){
          information+=",性別="+strSex;
          if(!strBirthday.equals(""))
          information+=", 出生年月="+strBirthday;
          if(!strSpeciality.equals(""))
          information+=",專業(yè)="+strSpeciality;
          if(!strAddress.equals(""))
          information+=",籍貫="+strAddress;
          return information;
          }
          }
             }

          posted on 2008-10-21 20:56 郭興華 閱讀(114) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 来凤县| 昭平县| 图片| 东台市| 泾川县| 固安县| 周至县| 通辽市| 宜宾县| 巴彦淖尔市| 镶黄旗| 鹰潭市| 饶河县| 仙桃市| 类乌齐县| 无锡市| 来凤县| 常山县| 普陀区| 阿城市| 阳原县| 观塘区| 鹤壁市| 土默特左旗| 威信县| 钟山县| 宿州市| 江孜县| 邵东县| 尚义县| 永丰县| 沿河| 武汉市| 阿尔山市| 荆州市| 镇安县| 西和县| 兴海县| 平遥县| 四平市| 黎川县|