Skip to content

Instantly share code, notes, and snippets.

@hagbarddenstore
Forked from pbrewczynski/gist:7068010
Last active December 26, 2015 01:08
Show Gist options
  • Save hagbarddenstore/7068740 to your computer and use it in GitHub Desktop.
Save hagbarddenstore/7068740 to your computer and use it in GitHub Desktop.
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");
}
}
}
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