blob: 1e7402127e807db6492f70cfd24a00b69fcaf57b (
plain)
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
36
37
38
|
using System.Collections.Generic;
using System.IO;
namespace TSP
{
public struct Coordinate
{
public int X { get; set; }
public int Y { get; set; }
public Coordinate(int x, int y)
{
X = x;
Y = y;
}
public Coordinate(string coords)
{
string[] items = coords.Split(',');
X = int.Parse(items[0]);
Y = int.Parse(items[1]);
}
public static List<Coordinate> Parse(string file)
{
List<Coordinate> coordinates = new List<Coordinate>();
foreach (string coords in File.ReadAllLines(file))
coordinates.Add(new Coordinate(coords));
return coordinates;
}
public override string ToString() => $"({X}, {Y})";
}
}
|