diff --git a/.vscode/settings.json b/.vscode/settings.json index daab734..1c0f27b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "dotnet.defaultSolution": "FirstProject.sln", - "editor.fontSize": 14, + "editor.fontSize": 20, "window.zoomLevel": 1, "terminal.integrated.fontSize": 14, "workbench.tree.indent": 23 diff --git a/Algorithms/Exercices1.cs b/Algorithms/Exercices1.cs new file mode 100644 index 0000000..39dd9c5 --- /dev/null +++ b/Algorithms/Exercices1.cs @@ -0,0 +1,37 @@ +namespace Algorithms; +using System; +using Algorithms.NumberTheory; + +class SolutionExercices1 { + + public static string removeTitle(string header) + { + int idx = header.IndexOf("."); + return header.Substring(idx + 1); + } + + public static void printEachDirectoryOnPath(string path) + { + string[] subs = path.Split(':'); + + foreach (var sub in subs) + { + Console.WriteLine(sub); + } + } + + public static void Main_(String[] args){ + // {titre}.{sous-titre}.{sous-sous- titre} + // 4.56.2 -> 56.2 + // 4.b.ii -> b.ii + string header = "4.56.2"; + 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" + + + string? path = Environment.GetEnvironmentVariable("PATH"); + printEachDirectoryOnPath(path ?? ""); + } +} \ No newline at end of file diff --git a/Algorithms/NumberTheory/Simple.cs b/Algorithms/NumberTheory/Simple.cs new file mode 100644 index 0000000..ccbd563 --- /dev/null +++ b/Algorithms/NumberTheory/Simple.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Algorithms.NumberTheory; + +class Simple +{ + internal double d; + + public Simple(double d) { + this.d = d; + } +} diff --git a/Algorithms/Point.cs b/Algorithms/Point.cs new file mode 100644 index 0000000..8c65485 --- /dev/null +++ b/Algorithms/Point.cs @@ -0,0 +1,64 @@ +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()); + } + +} + +class Point2 +{ + + private double x; + private double y; + + public Point2(double x, double y) + { + this.x = x; + this.y = y; + } + + public double X + { + get => x; + set => x = value; + } +} + + +class Manager +{ + internal string name; + private int level; + + public Manager(string name, int level){ + this.name = name; + this.level = level; + } + +} \ No newline at end of file diff --git a/Algorithms/Program.cs b/Algorithms/Program.cs index f8f3751..5f3d54f 100644 --- a/Algorithms/Program.cs +++ b/Algorithms/Program.cs @@ -1,26 +1,28 @@ // See https://aka.ms/new-console-template for more information namespace Algorithms; using System; +using Algorithms.NumberTheory; -class Point{ - - private double x; - private double y; - - public Point(double x, double y){ - this.x = x; - this.y = y; +class Program +{ + + public static void printEachDirectoryOnPath(string path) + { + string[] subs = path.Split(':'); + + foreach (var sub in subs) + { + Console.WriteLine(sub); + } } - - public double Distance(){ - return Math.Sqrt(x * x + x * y); - } -} -class Foo{ - public static void Main(String[] args){ - Point p = new Point(3, 4); - Console.WriteLine("Hello World From A Class: " + p.Distance()); + public static void Main(String[] args) + { + Point point = new Point(0, 0); + Point point2 = new Point(10, 10); + Console.WriteLine("La valeure de X de point est: " + point.X()); + Console.WriteLine("La valeure de X de point2 est: " + point2.X()); + } } diff --git a/Algorithms/TrigonometryUtil.cs b/Algorithms/TrigonometryUtil.cs new file mode 100644 index 0000000..4aceaf8 --- /dev/null +++ b/Algorithms/TrigonometryUtil.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Algorithms; + + +class TrigonometryUtil { + + public static double Side(double hypothenuse, double otherSide){ + return Math.Sqrt(hypothenuse * hypothenuse - otherSide * otherSide); + } + + public static double Hypothenuse(double a, double b){ + return Math.Sqrt(a * a + b * b); + } + + public static double Area(double hypothenuse, double side){ + double otherSide = Side(hypothenuse, side); + return side * otherSide * 0.5; + } +} \ No newline at end of file