summary refs log tree commit diff stats
path: root/java/code/EmployeeDisplay.java
blob: 6642540278e531f2c9f1945305674663d0a6b13e (plain) (blame)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class Employee {
	int id;
	String name;
	Employee(int eid, String ename) {
		id = eid;
		name = ename;
	}
	public String toString() {
		return "Employee named \"" + name + "\" with ID " + id + ".";
	}
}

class Scientist extends Employee {
	int number_of_publications, experience;
	Scientist(int sid, String sname, int nopubs, int yexp) {
		super(sid, sname);
		number_of_publications = nopubs;
		experience = yexp;
	}
	public String toString() {
		return "Scientist named \"" + name + "\" with ID " + id +
			", " + number_of_publications + " publications and " +
			experience + " years of experience" + ".";
	}
}

class DScientist extends Scientist {
	String[] award;
	DScientist(int sid, String sname, int nopubs, int yexp,
			String[] dsaward) {
		super(sid, sname, nopubs, yexp);
		award = dsaward;
	}
	public String toString() {
		return "Distinguished scientist named \"" + name +
			"\" with ID " + id +
			", " + number_of_publications + " publications, " +
			experience + " years of experience and awardee of " +
			String.join(", ", award) + ".";
	}
}

class EmployeeDisplay {
	public static void main(String args[]) {
		Employee e;
		e = new Employee(87416846, "Kim Ji-hyung");
		System.out.println(e);
		e = new Scientist(14534, "Daniel Lemire", 80, 25);
		System.out.println(e);
		e = new DScientist(11, "Donald Ervin Knuth", 185, 60,
				new String[] { "Grace Murray Hopper Award (1971)", 
					"Turing Award (1974)", "National Medal of Science (1979)", 
					"John von Neumann Medal (1995)", "Harvey Prize (1995)",
					"Kyoto Prize (1996)", "Faraday Medal (2011)"});
		System.out.println(e);
	}
}