數(shù)據(jù)加載中……
          StudentTest.java
          /*
          *學(xué)生類(lèi),包括學(xué)生類(lèi)的基本信息
          */
          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;
          }

          }

          }

          posted on 2008-10-21 18:16 郭興華 閱讀(217) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 丰镇市| 民勤县| 务川| 巴中市| 迁西县| 尉氏县| 双江| 伊川县| 大竹县| 扎兰屯市| 盘锦市| 泸州市| 准格尔旗| 福安市| 涟源市| 南华县| 星座| 石家庄市| 长葛市| 吉林市| 札达县| 洱源县| 广水市| 安溪县| 洞头县| 杭锦旗| 桃园市| 上虞市| 襄汾县| 遂昌县| 紫阳县| 南昌县| 汽车| 盐源县| 喀喇沁旗| 汝州市| 张掖市| 晋城| 赤壁市| 晴隆县| 金塔县|