请用Java代码定义一个部门类Department 属性:部门编号、部门名称、部门人数、部门职责、部门经理 定义两个构造方法:无参和有参各一 定义成员方法:输出信息printDetail() --------------------------- 其有一个子类研发部类ResearchDept 属性:研发方向speciality 在构造方法中调用父类构造方法 重写printDetail()方法
时间: 2023-04-03 14:03:26 浏览: 289
6208.2021年网络管理软件行业商务部门模板汇总_已压缩.pdf
以下是Java代码:
```
public class Department {
private String deptId;
private String deptName;
private int numOfEmployees;
private String responsibilities;
private String manager;
public Department() {}
public Department(String deptId, String deptName, int numOfEmployees, String responsibilities, String manager) {
this.deptId = deptId;
this.deptName = deptName;
this.numOfEmployees = numOfEmployees;
this.responsibilities = responsibilities;
this.manager = manager;
}
public void printDetail() {
System.out.println("部门编号:" + deptId);
System.out.println("部门名称:" + deptName);
System.out.println("部门人数:" + numOfEmployees);
System.out.println("部门职责:" + responsibilities);
System.out.println("部门经理:" + manager);
}
}
public class ResearchDept extends Department {
private String speciality;
public ResearchDept(String deptId, String deptName, int numOfEmployees, String responsibilities, String manager, String speciality) {
super(deptId, deptName, numOfEmployees, responsibilities, manager);
this.speciality = speciality;
}
@Override
public void printDetail() {
super.printDetail();
System.out.println("研发方向:" + speciality);
}
}
```
阅读全文