From e5d6fee9dc2a59298b646d45a0c4ec9b8fc0c124 Mon Sep 17 00:00:00 2001
From: MarcUs7i <96580944+MarcUs7i@users.noreply.github.com>
Date: Mon, 20 Jan 2025 21:02:44 +0100
Subject: [PATCH] Implemented all functions for BuildingInformation.cs
---
BuildingDirectory/BuildingInformation.cs | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/BuildingDirectory/BuildingInformation.cs b/BuildingDirectory/BuildingInformation.cs
index 9af78ac..8d83423 100644
--- a/BuildingDirectory/BuildingInformation.cs
+++ b/BuildingDirectory/BuildingInformation.cs
@@ -22,8 +22,7 @@ public sealed class BuildingInformation
/// Returns all floors in the building
///
/// A list of available floors
- // TODO
- public List GetFloorSelection() => new();
+ public List GetFloorSelection() => _companiesPerFloor.GetKeys();
///
/// Returns all companies residing on a specific floor.
@@ -31,8 +30,11 @@ public sealed class BuildingInformation
///
/// The floor to check
/// A list of names of companies residing on the provided floor
- // TODO
- public List? GetCompaniesOnFloor(Floor floor) => null;
+ public List? GetCompaniesOnFloor(Floor floor)
+ {
+ _companiesPerFloor.TryGetValue(floor, out MyDictionary? companies);
+ return companies?.GetKeys();
+ }
///
/// Returns the company identified by floor and company name.
@@ -41,6 +43,13 @@ public sealed class BuildingInformation
/// Floor to look at
/// Name of the requested company
/// Company information if found; null otherwise
- // TODO
- public Company? GetCompany(Floor floor, string companyName) => null;
+ public Company? GetCompany(Floor floor, string companyName)
+ {
+ //Needed to declare here, else you get an initialization error
+ Company? company = null;
+
+ _companiesPerFloor.TryGetValue(floor, out MyDictionary? companies);
+ companies?.TryGetValue(companyName, out company);
+ return company;
+ }
}
\ No newline at end of file