summary refs log tree commit diff stats
path: root/java
diff options
context:
space:
mode:
authorSudipto Mallick <smlckz@bccr>2024-01-08 14:45:46 +0530
committerSudipto Mallick <smlckz@bccr>2024-01-08 14:45:46 +0530
commitdb46ee7baa4e8dca6cc3f0fd8b42e4cc94ef8dd3 (patch)
tree832bd22ac923e9d257cf820ab1fe3b5938d60bf8 /java
parent77a06188a4cec38407578d2a4f78e22de308583a (diff)
downloadzadania-db46ee7baa4e8dca6cc3f0fd8b42e4cc94ef8dd3.tar.gz
Implement Java Assignment #17
Diffstat (limited to 'java')
-rw-r--r--java/code/EmployeeDisplay.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/java/code/EmployeeDisplay.java b/java/code/EmployeeDisplay.java
new file mode 100644
index 0000000..6642540
--- /dev/null
+++ b/java/code/EmployeeDisplay.java
@@ -0,0 +1,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);
+	}
+}
+