1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| package SuperSub;
public class Manager01 {
int no;
String name;
int salary;
String grade;
Employee[] empList; // 관리사원 목록
Manager01(int no, String name, int salary, String grade, Employee[] empList){
this.no = no;
this.name = name;
this.salary = salary;
this.grade = grade;
this.empList = empList;
}
void info() {
System.out.println();
System.out.println("사원번호 : " + no + ", 사원명 : " + name
+ ", 연봉 : " + salary + "만원 , 직급 : " + grade);
System.out.println("===============================================");
System.out.println("\t관리사원 목록");
System.out.println("===============================================");
for(Employee e : empList) {
e.info();
}
System.out.println("===============================================");
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| package SuperSub;
public class Manager02 extends Employee {
Employee[] empList; // 관리사원 목록
Manager02(int no, String name, int salary, String grade, Employee[] empList){
this.no = no;
this.name = name;
this.salary = salary;
this.grade = grade;
this.empList = empList;
}
@Override
void info() {
System.out.println();
super.info();
print();
System.out.println("\t\t관리사원 목록");
print();
for(Employee e : empList) {
e.info();
}
print(); }
void print() {
System.out.println("================================================");
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| package SuperSub;
public class Manager03 extends Employee {
Employee[] empList; // 관리사원 목록
Manager03(int no, String name, int salary, String grade, Employee[] empList){
super(no, name, salary, grade); // 부모 생성자 호출
/*
this.no = no; // super class의 멤버변수가 private면 직접 접근이 불가능하다.
this.name = name;
this.salary = salary;
this.grade = grade;
*/
this.empList = empList;
}
@Override
void info() {
System.out.println();
super.info();
print();
System.out.println("\t\t관리사원 목록");
print();
for(Employee e : empList) {
e.info();
}
print(); }
void print() {
System.out.println("================================================");
}
}
|