public void CheckIn(int id, string stationName, int t) { if (!CheckInMap.ContainsKey(id)) { CheckInMap[id] = new StationAndTimePair(); } CheckInMap[id].StationName = stationName; CheckInMap[id].Time = t; }
public void CheckOut(int id, string stationName, int t) { if (CheckInMap.ContainsKey(id)) { var startStation = CheckInMap[id].StationName; var startTime = CheckInMap[id].Time; var distance = t - startTime; if (!AverageTimeMap.ContainsKey(startStation)) { AverageTimeMap.Add(startStation, new Dictionary <string, ResultPair>()); } if (!AverageTimeMap[startStation].ContainsKey(stationName)) { AverageTimeMap[startStation].Add(stationName, new ResultPair()); } AverageTimeMap[startStation][stationName].NumberOfSets += 1; AverageTimeMap[startStation][stationName].TotalDifference += distance; } }