public static int IndexOfCommodity(Station outputStation, string commodityName) { for (int i = 0; i < outputStation.Commodities.Count; i++) if (outputStation.Commodities[i].Name.Contains(commodityName)) return i; return -1; }
public Station(Station copy) { commodities = new List<Commodity>(); name = copy.Name; system = copy.SystemName; foreach (Commodity commodity in copy.Commodities) commodities.Add(new Commodity(commodity)); }
public Trade(Trade copy) { commodity = new Commodity(copy.Commodity); startSystem = new StarSystem(copy.StartSystem); endSystem = new StarSystem(copy.EndSystem); startStation = new Station(copy.StartStation); endStation = new Station(copy.EndStation); unitsBought = copy.UnitsBought; score = copy.Score; }
public static void UpdateCommodities(Station outputStation, List<Commodity> outputCommodity) { int found; for (int i = 0; i < outputCommodity.Count; i++) { found = IndexOfCommodity(outputStation, outputCommodity[i].Name); if (found == -1) // Commodity not found, Add outputStation.Commodities.Add(outputCommodity[i]); else // Commodity found, Update // Only update if newer if (outputStation.Commodities[found].LastUpdated < outputCommodity[i].LastUpdated) outputStation.Commodities[found] = outputCommodity[i]; } }