Java--教師類


 
         
package com.company;
class teacher
{
    int number;
    String name ;
    String borndate ;
    String sex;
    String workplace ;
    String position ;

    void show()
    {
        System.out.print(+number+" ");
        System.out.print( name+" " );
        System.out.print( sex+" " );
        System.out.print( borndate+" " );
        System.out.print( position+" ");
        System.out.println( workplace+" " );
        System.out.print("研究 ");
        System.out.print("實驗 ");
        System.out.print("行政 ");
        System.out.println("圖書管理");
    }
}
class student extends teacher
{
    String grade;
    void show()
    {
        System.out.print(+number+" ");
        System.out.print( name+" " );
        System.out.print( sex+" " );
        System.out.print( borndate+" " );
        System.out.print( position+" ");
        System.out.print( grade+" " );
        System.out.println( workplace+" " );
        System.out.print("吃飯 ");
        System.out.print("學習 ");
        System.out.print("睡覺 ");
        System.out.println("看書");

    }
}
public class Main {

    public static void main(String[] args) {
        // write your code here
        teacher t = new teacher();
        student s = new student();
        t.borndate = ("2000/9/9");
        t.name = ("張三");
        t.number = 1195;
        t.position= "老師";
        t.sex="男";
        t.workplace="教師辦公室";
        s.borndate = ("2018/9/9");
        s.name = ("李四");
        s.number = 1000;
        s.position= "學生";
        s.sex="男";
        s.workplace="教室";
        s.grade="三年級";
        t.show();
        s.show();


    }
}
 
         

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM