ex-col-05-building-directory/BuildingDirectory/Model/Company.cs

45 lines
No EOL
1.5 KiB
C#

namespace BuildingDirectory.Model;
/// <summary>
/// Represents a company with employees
/// </summary>
public sealed class Company
{
private readonly MyDictionary<BusinessCard, int> _employeeRooms;
/// <summary>
/// Creates a new instance of a company with the given name and the employees together
/// with their room numbers.
/// Employees are represented/identified by their <see cref="BusinessCard"/>
/// </summary>
/// <param name="employeeRooms">Employees and assigned room numbers</param>
/// <param name="name">Name of the company</param>
public Company(MyDictionary<BusinessCard, int> employeeRooms, string name)
{
_employeeRooms = employeeRooms;
Name = name;
}
/// <summary>
/// Gets the name of the company
/// </summary>
public string Name { get; }
/// <summary>
/// Gets the number of employees working for the company
/// </summary>
public int NoOfEmployees => _employeeRooms.Count;
/// <summary>
/// Returns the room number the clerk identified by the provided
/// <see cref="BusinessCard"/> resides at - if known
/// </summary>
/// <param name="businessCard">Identification of the employee</param>
/// <returns>Room number if found; null otherwise</returns>
public int? AskForRoom(BusinessCard businessCard)
{
bool found = _employeeRooms.TryGetValue(businessCard, out int room);
return found ? room : null;
}
}