added Algorithms/SierpinskiTriangle.cs

This commit is contained in:
didier amyot committed 2023-08-28 09:30:26 -04:00
1 parent 6acd8c8ff1
commit a832521bda
7 files changed
+137 -4

No files matched your search

+12 -1
View File
@@ -1,6 +1,6 @@
namespace Algorithms;
using System;
class Point
public class Point
{
private double x;
private double y;
@@ -26,6 +26,13 @@ class Point
return Math.Sqrt(X() * X() + Y() * Y());
}
public double Distance(Point other)
{
double xDiff = X() - other.X();
double yDiff = Y() - other.Y();
return Math.Sqrt(xDiff * xDiff + yDiff*yDiff);
}
public Point MidPointOf(Point other)
{
double midX = (X() + other.X()) / 2;
@@ -33,4 +40,8 @@ class Point
return new Point(midX, midY);
}
public override string ToString(){
return "{\"x\": " + this.x + ", \"y\": " + this.y + "}";
}
}