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();


    }
}

 

 

 

posted @ 2020-12-22 00:41  zhou小月  阅读(2027)  评论(0编辑  收藏  举报