Answered by:
How to count a distance when travelling through several stations on the same line?

Question
-
public double TravelTimeOnSameLine(IStation from, IStation to, int speed) { //check values if (from == to || from == null || to == null || speed <= 0) throw new ArgumentException(); var commonLines = from.Lines.Intersect(to.Lines); if (!commonLines.Any()) { throw new ArgumentException(); } var line = commonLines.First(); var distance = 0.0; //Calcul path between stations (find the stations) if (to == line.Next(to)) { foreach (var finalStation in _stations) //for (int numberOfStations = 0; numberOfStations > 1; numberOfStations++) //{ // numberOfStations++; //} //return GetDistancebtween(x1: from.X, y1: from.Y, x2: to.X, y2: to.Y); return GetDistancebtween(x1: from.X, y1: from.Y, x2: to.X, y2: to.Y); } //then calcul distance (between all the stations) double dis = GetDistancebtween(x1: from.X, y1: from.Y, x2: to.X, y2: to.Y); distance += dis; var travelTime = distance / speed; return travelTime; }
I am trying to pass a last unit test and I am missing the calculation when I count a travel time through multiple stations.
public void T3_travel_time_on_more_stations() { ICity city = CityFactory.CreateCity("Paris"); IStation a = city.AddStation("A", 0, 0); IStation b = city.AddStation("B", 0, 10); IStation c = city.AddStation("C", 10, 10); IStation d = city.AddStation("D", 10, 0); ILine l1 = city.AddLine("ligne 1"); l1.AddBefore(a); l1.AddBefore(b); l1.AddBefore(c); l1.AddBefore(d); city.TravelTimeOnSameLine( a, d, 1).Should().Be(30.0); }
- Moved by Dave PatrickMVP Tuesday, January 14, 2020 1:40 PM looking for forum
Tuesday, January 14, 2020 1:23 PM
Answers
-
Perhaps ask here:
https://social.msdn.microsoft.com/Forums/en-us/home?forum=csharpgeneral
Richard Mueller - MVP Enterprise Mobility (Identity and Access)
- Edited by Richard MuellerMVP Tuesday, January 14, 2020 1:50 PM
- Proposed as answer by Guido Franzke Tuesday, January 14, 2020 2:29 PM
- Marked as answer by Richard MuellerMVP Tuesday, January 21, 2020 12:41 PM
Tuesday, January 14, 2020 1:39 PM -
I'd try asking for help over here.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=vslanguages
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.- Proposed as answer by Guido Franzke Tuesday, January 14, 2020 2:29 PM
- Marked as answer by Richard MuellerMVP Tuesday, January 21, 2020 12:41 PM
Tuesday, January 14, 2020 1:39 PM
All replies
-
Perhaps ask here:
https://social.msdn.microsoft.com/Forums/en-us/home?forum=csharpgeneral
Richard Mueller - MVP Enterprise Mobility (Identity and Access)
- Edited by Richard MuellerMVP Tuesday, January 14, 2020 1:50 PM
- Proposed as answer by Guido Franzke Tuesday, January 14, 2020 2:29 PM
- Marked as answer by Richard MuellerMVP Tuesday, January 21, 2020 12:41 PM
Tuesday, January 14, 2020 1:39 PM -
I'd try asking for help over here.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=vslanguages
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.- Proposed as answer by Guido Franzke Tuesday, January 14, 2020 2:29 PM
- Marked as answer by Richard MuellerMVP Tuesday, January 21, 2020 12:41 PM
Tuesday, January 14, 2020 1:39 PM