//static void TestLine() //Tests every method and accessor of the Line() class using the precribed //float testData[]; marked down below down below. public static void TestLine() { //TEST DATA----------------! float[] testData = new float[] { -2.0f, (float)Math.Sqrt(2.0), 1.0f, 0.333f, -0.0f, 22.0f, 1000.0001f, }; Console.WriteLine("\nTesting Line class...\n"); float angleStep = (float)Math.PI / testData.Count(); int numLines = testData.Count(); Line[] lines = new Line[numLines]; for (int t = 0; t < testData.Count(); t++) { Console.WriteLine("\nTest {0}\n", t + 1); int indexA = (t * 2) % testData.Count(); int indexB = ((t * 2) + 1) % testData.Count(); int indexC = ((t * 2) + 2) % testData.Count(); int indexD = ((t * 2) + 3) % testData.Count(); float valueA = testData[indexA]; float valueB = testData[indexB]; float valueC = testData[indexC]; float valueD = testData[indexD]; //Line paraA = lines[indexA] + lines[indexD]; Point p1 = new Point(valueA, valueB); Point p2 = new Point(valueC, valueD); Line l = new Line(p1, p2); lines[t] = l; Console.WriteLine("Testing with values {0}, {1}, {2}", valueA, valueB, valueC); Console.WriteLine("ToString() : " + l.ToString()); Console.WriteLine("Length : {0}", l.Length); Console.WriteLine("Midpoint : {0}", l.Midpoint); Console.WriteLine("Delta : {0}", l.Delta); float angle = angleStep * t; Polar polar = new Polar(angle, 10.0f); l.Polar = new Polar(angle, 10.0f); Console.WriteLine("SetPolar : Angle:{0}, Radius:{1} -> Result: {2}", polar.angle, polar.radius, l); polar = l.Polar; Console.WriteLine("GetPolar : Angle:{0}, Radius:{1}", polar.angle, polar.radius); } Console.WriteLine("\nTesting IsParallel method...\n"); for (int l = 0; l < lines.Count(); l++) { Console.WriteLine("Is ({0}) parallel with ({1}) ?", lines[0], lines[l]); if (lines[0].IsParallel(lines[l])) { Console.WriteLine("They are parallel."); } else { Console.WriteLine("They are not parallel."); } } Console.WriteLine("\nTesting ToPoints method...\n"); Point[] points = Line.ToPoints(lines); Console.WriteLine("Lines:"); for (int l = 0; l < lines.Count(); l++) { Console.Write(lines[l].ToString() + " | "); } Console.WriteLine("\nPoints:"); for (int p = 0; p < points.Count(); p++) { Console.Write(points[p].ToString() + " | "); } }
public override string ToString() { return(line.ToString()); }