用Java写PTA 7-9 校园角色类设计-1

用Java写PTA 7-9 校园角色类设计-1
学校需要构建综合系统,使用者包含多种角色。角色Role分两类:学生Student和雇员Employee;雇员又分为教员Faculty和职员Staff。
每个角色都有姓名、性别。学生有学号、班级。一个雇员有工号、入职日期。教员有职称。职员有职位称号。
请以如下Main类为基础,构建各个角色类,将代码补充完整。

public class Main {
    public static void main(String[] args) {
        Faculty fac = new Faculty("张三",32,"33006","2019","10","25","讲师");
        Student stu=new Student("李四",19,"20201103","202011");
        Staff sta = new Staff("王五",27,"32011","2015","06","17","教务员");        
        fac.show();
        sta.show();
        stu.show();
    }
}

输入格式:

输出格式:
我是张三,年龄32岁。工号是33006,2019年10月25日入职。是一名教师,讲师职称。
我是王五,年龄27岁。工号是32011,2015年6月17日入职。是一名教务员。
我是李四,年龄19岁。学号是20201103,来自202011班。

输入样例:
在这里给出一组输入。例如:

输出样例:
在这里给出相应的输出。例如:

我是张三,年龄32岁。工号是33006,2019年10月25日入职。是一名教师,讲师职称。
我是王五,年龄27岁。工号是32011,2015年6月17日入职。是一名教务员。
我是李四,年龄19岁。学号是20201103,来自202011班。

class Faculty{
    String name;
    int age;
    String id;
    String year,month,day;
    String title;
    Faculty(String name,int age,String id,String year,String month,String day,String title){
        this.name=name;
        this.age=age;
        this.id=id;
        this.year=year;
        this.month=month;
        this.day=day;
        this.title=title;
    }
       void  show(){
    	   System.out.println("我是"+name+",年龄"+age+"岁。工号是"+id+","+year+"年"+month+"月"+day+"日入职。是一名教师,"+title+"职称。");
  }
    }

   class Staff{
	   String name;
    int age;
    String id;
    String year,month,day;
    String title;
     Staff(String name,int age,String id,String year,String month,String day,String title){
        this.name=name;
        this.age=age;
        this.id=id;
        this.year=year;
        this.month=month;
        this.day=day;
        this.title=title;
     }
         void  show(){
        	 System.out.println("我是"+name+",年龄"+age+"岁。工号是"+id+","+year+"年"+month+"月"+day+"日入职。是一名"+title+"。");
  }
   }
   class Student{
           String name;
    int age;
    String id;
    String bj;
     Student(String name,int age,String id,String bj){
        this.name=name;
        this.age=age;
        this.id=id;
        this.bj=bj;
     }
       void show(){
      System.out.println("我是"+name+",年龄"+age+"岁。学号是"+id+",来自"+bj+"班。");
  }
   } 
  

       public class Main{
    public static void main(String[] args) {
        Faculty fac = new Faculty("张三",32,"33006","2019","10","25","讲师");
        Student stu=new Student("李四",19,"20201103","202011");
        Staff sta = new Staff("王五",27,"32011","2015","6","17","教务员");        
        fac.show();
        sta.show();
        stu.show();
    }
}
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

এ᭄南书ོꦿృ

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值