/
Company.cs
38 lines (32 loc) · 1.06 KB
/
Company.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Create a custom type for Company. A company has the following properties.
// Date founded (DateTime)
// Company name (string)
// Employees (List<Employee>)
using System;
using System.Collections.Generic;
namespace Classes
{
public class Company
{
public string name { get; }
public DateTime createdOn { get; }
// Create a public property for holding a list of current employees
public HashSet<Employee> EmployeeList = new HashSet<Employee>();
public Company(string NameOfComapany, DateTime CreationDate)
{
name = NameOfComapany;
createdOn = CreationDate;
}
public void NewHire(Employee applicant)
{
EmployeeList.Add(applicant);
}
public void DisplayEmployees()
{
foreach (Employee representative in EmployeeList)
{
Console.WriteLine($"{representative.firstName} {representative.lastName} works for {name} as {representative.title} since {representative.startDate} ");
}
}
}
}