/// <summary> /// A function that returns true if it has added a neighbour /// </summary> /// <param name="area">From area</param> /// <param name="xOffset">X Offset for finding neighbour</param> /// <param name="yOffset">Y Offset for finding neighbour</param> /// <param name="weight">The weight that is given to the edge</param> /// <returns>True if a neighbour has been added, otherwise false</returns> private bool AddNeighbour(IArea area, int xOffset, int yOffset, int weight) { if (!(HotelAreas.Find(X => X.Position == new Point(area.Position.X + xOffset, area.Position.Y + yOffset)) is null)) { area.Edge.Add(HotelAreas.Find(X => X.Position == new Point(area.Position.X + xOffset, area.Position.Y + yOffset)), weight); return(true); } return(false); }
/// <summary> /// Handles checkin events and add the ariving guest to the list /// </summary> /// <param name="evt">The given event</param> public void Notify(HotelEvent evt) { if (evt.EventType.Equals(HotelEventType.CHECK_IN)) { string name = string.Empty; string request = string.Empty; int requestInt; int id = 0; if (!(evt.Data is null)) { foreach (var DataSet in evt.Data) { if (DataSet.Key.Contains("Gast")) { id = int.Parse(Regex.Match(DataSet.Key, @"\d+").Value); } } name = evt.Data.FirstOrDefault().Key; request = evt.Data.FirstOrDefault().Value; requestInt = int.Parse(Regex.Match(request, @"\d+").Value); } else { // Kill test events return; } Guest guest = new Guest(this, name, requestInt, new Point(0, HotelHeight), id) { Area = HotelAreas.Find(X => X.Position == new Point(0, HotelHeight)) }; guest.Area = HotelAreas.Find(X => X.Position == guest.Position); guest.Hotel = this; ArivingGuests.Add(guest); }