java技術博客

          jsp博客
          數據加載中……
          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="學生姓名="+strName+",學號="+strNumber;
          if(!strSex.equals("")){
          information+=",性別="+strSex;
          if(!strBirthday.equals(""))
          information+=", 出生年月="+strBirthday;
          if(!strSpeciality.equals(""))
          information+=",專業="+strSpeciality;
          if(!strAddress.equals(""))
          information+=",籍貫="+strAddress;
          return information;
          }
          }
             }

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


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


          網站導航:
           
          主站蜘蛛池模板: 峨眉山市| 泊头市| 忻城县| 肃宁县| 宁南县| 封开县| 于田县| 嵊州市| 洛阳市| 三台县| 勐海县| 水城县| 城市| 高尔夫| 涞源县| 锡林郭勒盟| 茂名市| 郸城县| 乐陵市| 临沭县| 乌拉特后旗| 平度市| 信丰县| 颍上县| 霍州市| 门源| 汉寿县| 灌云县| 镇远县| 义乌市| 循化| 孝昌县| 民丰县| 万安县| 青海省| 大安市| 休宁县| 仁寿县| 威信县| 会泽县| 安西县|