diff options
Diffstat (limited to 'src/CS340.TSP/Coordinates.cs')
-rw-r--r-- | src/CS340.TSP/Coordinates.cs | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/src/CS340.TSP/Coordinates.cs b/src/CS340.TSP/Coordinates.cs index f377c89..1e74021 100644 --- a/src/CS340.TSP/Coordinates.cs +++ b/src/CS340.TSP/Coordinates.cs @@ -1,17 +1,38 @@ -using Graph; -using Interfaces; +using System.Collections.Generic; +using System.IO; namespace TSP { - public struct Coordinates + public struct Coordinate { - public double X { get; set; } - public double Y { get; set; } + public int X { get; set; } + public int Y { get; set; } - public Coordinates(double x, double y) + 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})"; } } |