數(shù)據(jù)加載中……
          Student.java
          /**
           * 我們?cè)O(shè)計(jì)的學(xué)生基本類(lèi)
           
          */

          class Student
          {
              
          private String strName = "";//學(xué)生姓名
              private String strNumber = "";//學(xué)號(hào)
              private String strSex = "";//性別
              private String strBirthday = "";//出生年月
              private String strSpeciality = "";//專(zhuān)業(yè)
              private String strAddress = "";//地址
              private double totalScore;//學(xué)生的總分?jǐn)?shù)
              
              
          public static void main(String[] args)
              
          {
                  String[] course 
          = {"計(jì)算機(jī)原理""編譯方法""數(shù)據(jù)結(jié)構(gòu)"};
                  Student one 
          = new Student("Tom","20021024");
                  one.setStudentCourse(course);
              }

              
              
          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 double getStudentScore()
              
          {
                  
          return totalScore;
              }

              
              
          public void setStudentScore(double score)
              
          {
                  totalScore 
          = score;
              }

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

          public void setStudentCourse(String[] strCourse)
              
          {
                  
          new Course(strCourse);
              }

              
              
          //內(nèi)部課程類(lèi)
              private class Course
              
          {
                  
          private String[] strCourse;//學(xué)生課程的數(shù)組
                  private int courseNumber;
                  
                  
          public Course(String[] course)
                  
          {
                      strCourse 
          = course;    
                      courseNumber 
          = course.length;
                      getDescription();        
                  }

                  
                  
          private void getCourse()
                  
          {
                      
          for(int i = 0; i < courseNumber; i++)
                      
          {
                          System.out.print(
          "\t" + strCourse[i]);
                      }

                  }

                  
                  
          private void getDescription()
                  
          {
                      System.out.println(
          "學(xué)生: " + Student.this.strName + " 學(xué)號(hào)是:" +
                                         Student.
          this.strNumber + "。 一共選了" + 
                                          courseNumber 
          + "門(mén)課,分別是:");
                      getCourse();
                  }
                  
              }

          }

              

          posted on 2008-10-23 00:08 郭興華 閱讀(194) 評(píng)論(0)  編輯  收藏


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 文化| 杭州市| 乳山市| 沅陵县| 潞城市| 新宾| 清镇市| 云南省| 舞钢市| 长泰县| 庄浪县| 潜山县| 高邑县| 嘉祥县| 泸溪县| 信丰县| 益阳市| 桂林市| 瓮安县| 长宁区| 临海市| 桐柏县| 海阳市| 广州市| 宜昌市| 嘉兴市| 应城市| 东宁县| 舟山市| 吴忠市| 云浮市| 莱阳市| 绍兴市| 安塞县| 滕州市| 晋州市| 西华县| 淮南市| 盐津县| 阳原县| 克什克腾旗|