Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace PointExercise
- {
- public class Route
- {
- List<Point> routeList= new List<Point>();
- /*public void Create_Route()
- {
- routeList = new List<Point>();
- }*/
- public void Add_Point(double x, double y,int index)
- {
- try
- {
- if (index >= 0 && index <= routeList.Count)
- {
- routeList.Insert(index, new Point(x, y));
- }
- }
- catch (ArgumentException)
- {
- Console.WriteLine("Add point failed");
- }
- }
- public void Remove_Point(int indeks)
- {
- try
- {
- routeList.RemoveAt(indeks);
- }
- catch (ArgumentException)
- {
- Console.WriteLine("Remove point failed");
- }
- }
- public double Get_Length()
- {
- double tulem =0;
- int i = 1;
- if (routeList.Count > 1)
- {
- foreach (var point in routeList)
- {
- if (routeList.Count > i)
- {
- tulem = point.distance(routeList[i]);
- i++;
- }
- }
- }
- return tulem ;
- }
- //For testing
- public int Get_ListCount()
- {
- return routeList.Count;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement