diff --git a/Algorithms/Exercices/FirstSet.cs b/Algorithms/Exercices/FirstSet.cs new file mode 100644 index 0000000..f9eab6e --- /dev/null +++ b/Algorithms/Exercices/FirstSet.cs @@ -0,0 +1,34 @@ +namespace Algorithms.Exercices; + +using System; + +class Solutions { + + public static string RemoveTitle(string header) + { + int idx = header.IndexOf("."); + return header.Substring(idx + 1); + } + + public static void MainExampleOfRemoveTitle(string[] args){ + Console.WriteLine(RemoveTitle("4.56.2")); // "56.2" + Console.WriteLine(RemoveTitle("4.b.ii")); // "b.ii" + Console.WriteLine(RemoveTitle("")); // "" + Console.WriteLine(RemoveTitle("4.b")); // "b" + } + + public static void PrintEachDirectoryOnPath(string path) + { + string[] subs = path.Split(':'); + + foreach (var sub in subs) + { + Console.WriteLine(sub); + } + } + + public static void MainExampleOfPrintEachDirectoryOnPath(String[] args){ + string? path = Environment.GetEnvironmentVariable("PATH"); + PrintEachDirectoryOnPath(path ?? ""); + } +} \ No newline at end of file diff --git a/Algorithms/Point.cs b/Algorithms/Point.cs new file mode 100644 index 0000000..7b4108e --- /dev/null +++ b/Algorithms/Point.cs @@ -0,0 +1,29 @@ +namespace Algorithms; +using System; +class Point +{ + private double x; + private double y; + + public Point(double x, double y) + { + this.x = x; + this.y = y; + } + + public double X() + { + return x; + } + + public double Y() + { + return y; + } + + public double Distance() + { + return Math.Sqrt(X() * X() + Y() * Y()); + } + +} \ No newline at end of file diff --git a/Algorithms/Program.cs b/Algorithms/Program.cs index f8f3751..7e9fc6b 100644 --- a/Algorithms/Program.cs +++ b/Algorithms/Program.cs @@ -2,25 +2,15 @@ namespace Algorithms; using System; -class Point{ - - private double x; - private double y; - - public Point(double x, double y){ - this.x = x; - this.y = y; - } - - public double Distance(){ - return Math.Sqrt(x * x + x * y); - } -} -class Foo{ +class EntryPoint{ + + public static void Main(String[] args){ - Point p = new Point(3, 4); + Point point1 = new Point(3, 4); + Point point2 = new Point(-3, -4); + Console.WriteLine("Hello World From A Class: " + p.Distance()); } }