java技術博客

          jsp博客
          數據加載中……
          StudentTest.java
          /*
          *學生類,包括學生類的基本信息
          */
          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 郭興華 閱讀(218) 評論(0)  編輯  收藏


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


          網站導航:
           
          主站蜘蛛池模板: 扎囊县| 崇州市| 齐河县| 依兰县| 泽普县| 聊城市| 贡嘎县| 梅河口市| 景洪市| 仲巴县| 江华| 卓尼县| 襄垣县| 格尔木市| 鹿泉市| 简阳市| 十堰市| 铁岭市| 靖宇县| 太谷县| 天等县| 盱眙县| 轮台县| 临沭县| 西乌珠穆沁旗| 平乐县| 寿阳县| 苍梧县| 紫云| 昌邑市| 咸阳市| 玉龙| 孙吴县| 怀集县| 腾冲县| 改则县| 白河县| 报价| 长白| 同仁县| 成都市|