-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRoute.cs
35 lines (33 loc) · 928 Bytes
/
Route.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Travelling_SalesMan_Problem
{
class Route
{
private ArrayList cities = new ArrayList();
public Route(ArrayList cities)
{
this.cities.AddRange(cities);
}
public ArrayList getCities()
{
return cities;
}
public double calculateTotalDistance()// it calculate the total distance between all cities
{
int citySize = this.cities.Count;
Double sum = 0;
for (int i = 0; i < citySize - 1; i++)
{
City currentCity = (City)this.cities[i];
City nextCity = (City)this.cities[i + 1];
sum += currentCity.measureDistance(nextCity);
}
return sum;
}
}
}