public static void Main(string[] args) { Point3D point = new Point3D(2.5, 1, 3); Point3D startingPoint = Point3D.GetStartingPoint; //Homework Problem 1 //Print point Console.WriteLine(point.ToString()); //Homework Problem 1 //Print starting point Console.WriteLine(startingPoint.ToString()); //Homework Problem 2 //Calculate and print dostance between point and starting point Console.WriteLine(DistanceCalculator.CalculateDistance(point, startingPoint)); //Homework Problem 3 //Create path and add two points Path3D path = new Path3D(); path.AddPoint(point); path.AddPoint(startingPoint); //Save file Storage.SavePath(path, filePath); //Load file Console.WriteLine(); Storage.LoadPath(filePath); }
public static void Main() { // The first three problems are in this project Point3D point = new Point3D(5.4m, 6.6m, 3.1m); Console.WriteLine(point); Point3D anotherPoint = new Point3D(1m, 5.78m, -2.75m); Console.WriteLine(anotherPoint); Console.WriteLine("{0:F3}", DistanceCalculation.CalculateDistance(point, anotherPoint)); Point3D basePoint = Point3D.StartingPoint; Console.WriteLine(basePoint); Path3D listOfPoints = new Path3D(); listOfPoints.AddPoint(point); listOfPoints.AddPoint(basePoint); listOfPoints.AddPoint(anotherPoint); Storage.SavePath(listOfPoints); }
public static void Main() { // Make two points var pointA = new Point(5, 6, 2); var pointB = new Point(-7, 11, -13); // Print the points Console.WriteLine("Point a: {0}", pointA); Console.WriteLine("Point b: {0}", pointB); Console.WriteLine(); // Calculate the distance double distance = DistanceCalculator.CalculateDistance(pointA, pointB); Console.WriteLine("Distance [a -> b] = {0:0.00}", distance); // Add a points to the List<> var path = new Path3D(); //path.AddPoint(pointA); path.AddPoint(pointB); // Save the points from the List<> to .txt Storage.SavePoint(path); Console.WriteLine(); // Load the points from the file Console.WriteLine("Loaded points:"); Storage.LoadPoint(); Console.WriteLine(); }
public static void LoadPoint() { var loadPath = new StreamReader(SavedPaths); var loadedPath = new Path3D(); using (loadPath) { string line = loadPath.ReadLine(); while (line != null) { var currentLine = line.Split(new char[] { ' ', ',', '=' }, StringSplitOptions.RemoveEmptyEntries); var currnetPath = new Point(double.Parse(currentLine[1]), double.Parse(currentLine[3]), double.Parse(currentLine[5])); loadedPath.AddPoint(currnetPath); line = loadPath.ReadLine(); } } foreach (var path in loadedPath.PathList) { Console.WriteLine(path); } }
static void Main() { Point3D point1 = new Point3D(-7, -4, 3); Point3D point2 = new Point3D(17, 6, 2.5); // Display Points Console.WriteLine("Starting point: " + Point3D.StartingPoint); Console.WriteLine("Point3D 1: " + point1); Console.WriteLine("Point3D 1: " + point2); // Display Distance Between Points double distance = DistanceCalculator.CalculateDistance(point1, point2); Console.WriteLine(); Console.WriteLine("Distance: " + distance); Console.WriteLine(); // Display Path Path3D path = new Path3D(point1, point2); path.AddPoint(new Point3D(4, 6.4, 11.1)); // if 3th value is true, the path will be appended to old file data, else the file will be overwritten Storage.SavePath("paths.txt", path, false); Console.WriteLine("Path: " + path); string storageData = Storage.LoadPath("paths.txt"); Console.WriteLine("\nPath from Storage:\n" + storageData); }
public static Path3D LoadPathFromFile(string fileName) { try { Path3D path = new Path3D(); using (StreamReader sr = new StreamReader(fileName)) { string input = sr.ReadToEnd(); string pattern = @"Point\(([\d.]+),([\d.]+),([\d.]+)\)"; Regex rgx = new Regex(pattern); MatchCollection matches = rgx.Matches(input); foreach (Match match in matches) { double x = double.Parse(match.Groups[1].Value); double y = double.Parse(match.Groups[2].Value); double z = double.Parse(match.Groups[3].Value); Point3D point = new Point3D(x, y, z); path.AddPoint(point); } } return(path); } catch (IOException ex) { Console.WriteLine(ex.Message); throw ex.InnerException; } }
static void Main() { Point3D point1 = new Point3D(-7, -4, 3); Point3D point2 = new Point3D(17, 6, 2.5); // Display Points Console.WriteLine("Starting point: " + Point3D.StartingPoint); Console.WriteLine("Point3D 1: " + point1); Console.WriteLine("Point3D 1: " + point2); // Display Distance Between Points double distance = DistanceCalculator.CalculateDistance(point1, point2); Console.WriteLine(); Console.WriteLine("Distance: " + distance); Console.WriteLine(); // Display Path Path3D path = new Path3D(point1, point2); path.AddPoint(new Point3D(4, 6.4, 11.1)); // if 3th value is true, the path will be appended to old file data, else the file will be overwritten Storage.SavePath("paths.txt", path, false); Console.WriteLine("Path: " + path); string storageData = Storage.LoadPath("paths.txt"); Console.WriteLine("\nPath from Storage:\n" + storageData); }
public static void Main() { Point3D point = new Point3D(3, 3, 3); Console.WriteLine(point); Console.WriteLine(Point3D.StartingPoint); var dist = DistanceCalculator.CalcDistance(point, Point3D.StartingPoint); Console.WriteLine("The distance between point One {0} and point two {1} is {2:F2}",point,Point3D.StartingPoint, dist); // testing Path3D Path3D pathToHome = new Path3D(); pathToHome.AddPoint(new Point3D(1, 2, 3)); pathToHome.AddPoint(new Point3D(2, 21, 3)); pathToHome.AddPoint(new Point3D(11, 0, 3)); pathToHome.AddPoint(new Point3D(1, 2, 3)); pathToHome.AddPoint(new Point3D(4, 5, 6)); pathToHome.AddPoint(new Point3D(7, 8, 8)); Console.WriteLine(pathToHome); //Testing Storage methods that save and load files with given 3dpa Storage.LoadPath(@"D:\Mirchev\SoftUni\OOP\StaticMembersAndNamespaces\Point3D\navigation.txt"); Storage.SavePath(@"D:\Mirchev\SoftUni\OOP\StaticMembersAndNamespaces\Point3D\naviToHome.txt", pathToHome); }