diff --git a/README.md b/README.md index ea6b048..0e4fe79 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Coding evaluation projects -These projects are intended to help AA interviewers to evaluate the coding skills of job candidates. The projects are all identical in nature, but implemented in different languages. \ No newline at end of file +This are SAMPLE Full stack Projects diff --git a/java/com/aa/act/interview/org/Organization.java b/java/com/aa/act/interview/org/Organization.java index 5060509..d99fa70 100644 --- a/java/com/aa/act/interview/org/Organization.java +++ b/java/com/aa/act/interview/org/Organization.java @@ -6,6 +6,8 @@ public abstract class Organization { private Position root; + private int identifier = 0; + public Organization() { root = createOrganization(); } @@ -21,9 +23,39 @@ public Organization() { */ public Optional hire(Name person, String title) { //your code here + + Optional employee = Optional.of(new Employee(++identifier, person)); + + Position position = getPositionByTitle(root, title); + if (position != null) + { + position.setEmployee(employee); + return Optional.of(position); + } + return Optional.empty(); } + public Position getPositionByTitle(Position position, String title) { + + if (position.getTitle().equals(title)) { + + return position; + } + + else { + for (Position pos : position.getDirectReports()) { + + Position pos1 = getPositionByTitle(pos, title); + if (pos1 != null) + return pos1; + + } + } + + return null; + } + @Override public String toString() { return printOrganization(root, "");