Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions java/com/aa/act/interview/org/Employee.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ public class Employee {

private int identifier;
private Name name;

public Employee(){
}
public Employee( Name name) {
if(name == null)
throw new IllegalArgumentException("name cannot be null");
this.name = name;
}

public Employee(int identifier, Name name) {
if(name == null)
Expand Down
7 changes: 6 additions & 1 deletion java/com/aa/act/interview/org/Name.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ public Name(String first, String last) {
this.first = first;
this.last = last;
}

public void setFirst(String first) {
this.first = first;
}
public String getFirst() {
return first;
}

public void setLast(String last) {
this.last = last;
}
public String getLast() {
return last;
}
Expand Down
22 changes: 21 additions & 1 deletion java/com/aa/act/interview/org/Organization.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,28 @@ public Organization() {
* @param title
* @return the newly filled position or empty if no position has that title
*/
public Optional<Position> findPosition(Position newPostion, String title) {
Optional<Position> newHire = Optional.of(newPosition);
if (newHire.get().getTitle().equals(title)) {
return newHire;
} else {
for (Position pos : newPosition.getDirectReports()) {
newHire = findPosition(pos, title);
if (newHire.isPresent()) {
return newHire;
}
}
}
return Optimal.empty();
}
public Optional<Position> hire(Name person, String title) {
//your code here
Optional<Position> newPosition = findPosition(root, title);
if (newPosition.isPresent()) {
Position pos = newPosition.get();
if (!pos.isFilled()) {
newPosition.get().setEmployee(Optional.of(new Employee(person)));
}
}
return Optional.empty();
}

Expand Down
4 changes: 4 additions & 0 deletions java/com/aa/act/interview/org/Position.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public class Position {
private Optional<Employee> employee;
private Set<Position> directReports;

public Position() { //default
}


public Position(String title) {
this.title = title;
employee = Optional.empty();
Expand Down