/// <summary> /// Used to check luggage in at terminal /// </summary> internal void Checkin(Luggage luggage) { Counter counter = Counters.FirstOrDefault(c => c.Id == luggage.CounterId); counter.Checkin(luggage); luggage.Reservation.IsCheckedIn = true; }
/// <summary> /// Used to check luggage in /// </summary> internal void Checkin(Luggage luggage) { if (Luggage == null) { Luggage = luggage; } else { throw new Exception("There is already luggage on counter!"); } }
/// <summary> /// Used to update the counter to sorter process /// </summary> private void UpdateCounterToSorterProcess() { if (ConveyorBelt.IsSpace()) { // Gets all counters there has luggage to go on the conveyor belt List <Counter> counters = this.counters.Where(c => c.IsLuggageReady()).ToList(); if (counters.Count != 0) { // Finds random counter Counter counter = counters[rng.Next(0, counters.Count)]; // Gets luggage Luggage luggage = counter.GetLuggageFromCounter(); // Push the luggage to the conveyor belt ConveyorBelt.Push(luggage); ProcessInfo?.Invoke($"Luggage owned by {luggage.Reservation.Passenger.FirstName} is now on the conveyor belt to terminal {luggage.TerminalId}"); } } }
/// <summary> /// Used to update the sorter to terminal process /// </summary> private void UpdateSorterToTerminalProcess() { // Check if next pull is not empty if (!ConveyorBelt.IsPullEmpty()) { // Pulls luggage from last index in the buffer Luggage luggage = ConveyorBelt.Pull(); // Finds the terminal where the luggage should goto Terminal terminal = terminals.FirstOrDefault(t => t.Id == luggage.TerminalId); if (terminal != null) { terminal.AddLuggage(luggage); // Adds luggage to terminal storage } ProcessInfo?.Invoke($"Luggage owned by {luggage.Reservation.Passenger.FirstName} is now in terminal {terminal.Id}"); } else { ConveyorBelt.MoveForward(); } }
/// <summary> /// Used to add luggage to terminal storage /// </summary> internal void AddLuggage(Luggage luggage) { Luggages.Enqueue(luggage); }