-
-
Save hagbarddenstore/7068740 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ProjectCompany | |
{ | |
public class Employee | |
{ | |
private string firstName; | |
private string secondName; | |
private Company company; | |
private Employee supervisor; | |
public Employee (string firstName, string secondName, Company company, Employee supervisor) | |
{ | |
this.firstName = firstName; | |
this.secondName = secondName; | |
this.company = company; | |
this.supervisor = supervisor; | |
} | |
private string fullName | |
{ | |
get | |
{ | |
return string.Format("{0} {1}", firstName, secondName); | |
} | |
} | |
public override string ToString() | |
{ | |
return string.Format("Supervisor of {0} is {1}", fullName, supervisor != null ? supervisor.fullName : "N/A"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ProjectCompany | |
{ | |
public static class Program | |
{ | |
private static readonly List<Employee> employees = new List<Employee>(); | |
public static void Main() | |
{ | |
// Add an employee... | |
AddEmployee(); | |
PrintEmployees(); | |
} | |
private static void AddEmployee() | |
{ | |
string firstName = string.Empty; | |
string secondName = string.Empty; | |
Console.Write("First name: "); | |
firstName = Console.ReadLine(); | |
Console.Write("Second name: "); | |
secondName = Console.ReadLine(); | |
// TODO: Find supervisor and company... | |
Company company = null; | |
Employee supervisor = null; | |
var employee = new Employee(firstName, secondName, company, supervisor); | |
employees.Add(employee); | |
} | |
private static void PrintEmployees() | |
{ | |
foreach (var employee in employees) | |
{ | |
Console.WriteLine(employee) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment