public void DropOff(string key, ICargoTransporter transporter) { Cargo cargo; List <Cargo> listOfCargo = new List <Cargo>(); while ((cargo = transporter.RemoveCargo()) != null) { listOfCargo.Add(cargo); } Storage[key] = listOfCargo; }
public void DropOff(string key, ICargoTransporter ship) { Cargo item; List <Cargo> load = new List <Cargo>(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"{ship.GetShipName()} is unloading at {name}. Key: {key}"); Console.ResetColor(); if (!ship.HasCargo()) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Nothing to unload."); Console.ResetColor(); return; } if (storage.ContainsKey(key)) { storage.TryGetValue(key, out load); load.Add(ship.RemoveCargo()); storage.Remove(key); storage.Add(key, load); Console.ForegroundColor = ConsoleColor.DarkGray; Console.WriteLine("This is an addition to an allready existing cargo."); Console.ResetColor(); return; } while ((item = ship.RemoveCargo()) != null) { load.Add(item); } storage.Add(key, load); Timer(); Console.WriteLine("Done"); }