Skip to content
Open
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
32 changes: 26 additions & 6 deletions dotnet/MyOrganization/Organization.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -9,7 +9,7 @@ namespace MyOrganization
internal abstract class Organization
{
private Position root;

int id=0;
public Organization()
{
root = CreateOrganization();
Expand All @@ -19,15 +19,35 @@ public Organization()

/**
* hire the given person as an employee in the position that has that title
*
*
* @param person
* @param title
* @return the newly filled position or empty if no position has that title
*/
public Position? Hire(Name person, string title)
public Position? Hire(Name person, String title)
{
addNewEmp(root, person, title);
displayEmpDetails(root, person, title);
return root;
}

private void addNewEmp(Position position, Name person, String title)
{
//add new emp/Hire
if (position.GetTitle().Equals(title))
{
position.SetEmployee(new Employee(++id, new Name(person.GetFirst(), person.GetLast())));
}

}
private void displayEmpDetails(Position pos, Name person, String title)
{
//your code here
return null;
//check direct report
foreach (Position p in pos.GetDirectReports())
{
addNewEmp(p, person, title);
displayEmpDetails(p, person, title);
}
}

override public string ToString()
Expand Down