diff --git a/source/Trek-12/ConsoleApp/Program.cs b/source/Trek-12/ConsoleApp/Program.cs index e1233a1..619f30e 100644 --- a/source/Trek-12/ConsoleApp/Program.cs +++ b/source/Trek-12/ConsoleApp/Program.cs @@ -1,3 +1,130 @@ // See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!");ss \ No newline at end of file + + +using Models; + +Position pos01 = new Position(0,0); +Position pos02 = new Position(1,0); +Position pos03 = new Position(2,0); +Position pos04 = new Position(3,0); +Position pos05 = new Position(4,0); + +Position pos11 = new Position(0, 1); +Position pos12 = new Position(1, 1); +Position pos13 = new Position(2, 1); +Position pos14 = new Position(3, 1); +Position pos15 = new Position(4, 1); + +Position pos21 = new Position(0, 2); +Position pos22 = new Position(1, 2); +Position pos23 = new Position(2, 2); +Position pos24 = new Position(3, 2); +Position pos25 = new Position(4, 2); + +Position pos31 = new Position(0, 3); +Position pos32 = new Position(1, 3); +Position pos33 = new Position(2, 3); +Position pos34 = new Position(3,3); +Position pos35 = new Position(4, 3); + +List list = new List(); +list.Add(pos01); +list.Add(pos02); +list.Add(pos03); +list.Add(pos04); +list.Add(pos05); + +list.Add(pos11); +list.Add(pos12); +list.Add(pos13); +list.Add(pos14); +list.Add(pos15); + +list.Add(pos21); +list.Add(pos22); +list.Add(pos23); +list.Add(pos24); +list.Add(pos25); + +list.Add(pos31); +list.Add(pos32); +list.Add(pos33); +list.Add(pos34); +list.Add(pos35); + + + +/*Pion pion1 = new Pion(une, 5); +Pion pion2 = new Pion(deux, 8); + +Console.WriteLine(pion1); +Console.WriteLine(pion2); + +List pions = new List() { pion1, pion2 }; + +int i = 0; + +foreach (var item in list) +{ + + Console.Write(" | "); + foreach (var pion in pions) + { + if (item.X == pion.Position.X && item.Y == pion.Position.Y) + { + Console.Write(pion); + } + } + i++; + if (i%2 == 0) Console.Write(" |\n"); +}*/ + + + +/*Pion pion1 = new Pion(pos35); +pion1.Select = true; + +Pion pion2 = new Pion(pos11); +pion2.Select = true; + +Console.WriteLine(pion1); + +List list2 = new List() { pion1,pion2 }; + + +int i = 0; + +foreach (var item in list) +{ + Console.Write(" | "); + foreach (var pion in list2) + { + if (pion.Select == true && pion.Position.X == item.X && pion.Position.Y == item.Y) Console.Write("X"); + } + i++; + if (i % 4 == 0) Console.Write(" |\n"); +}*/ + + +OperationsGrid grille = new OperationsGrid(); + + +grille.ResultGrid(Operation.ADDITION); +grille.ResultGrid(Operation.MULTIPLICATION); +grille.ResultGrid(Operation.LOWER); +grille.ResultGrid(Operation.MULTIPLICATION); +grille.ResultGrid(Operation.MULTIPLICATION); +grille.ResultGrid(Operation.HIGHER); + +int cpt = 0; +foreach (var item in grille.Tiles) +{ + Console.Write(" | "); + Console.Write(item); + cpt++; + if (cpt % 4 == 0) Console.Write(" |\n"); +} + + + diff --git a/source/Trek-12/Models/Operation.cs b/source/Trek-12/Models/Operation.cs new file mode 100644 index 0000000..7c92573 --- /dev/null +++ b/source/Trek-12/Models/Operation.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Models +{ + public enum Operation + { + LOWER, + HIGHER, + SUBTRACTION, + ADDITION, + MULTIPLICATION + } +} diff --git a/source/Trek-12/Models/OperationsGrid.cs b/source/Trek-12/Models/OperationsGrid.cs new file mode 100644 index 0000000..f5b4672 --- /dev/null +++ b/source/Trek-12/Models/OperationsGrid.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Models +{ + public class OperationsGrid + { + public bool[,] Tiles; + + public OperationsGrid() + { + Tiles = new bool[5,4]; + + } + + public void ResultGrid(Operation p) + { + switch (p) + { + case Operation.LOWER: + for (int i = 0; i < Tiles.GetLength(1); i++) { if (Tiles[0, i] == false) { Tiles[0, i] = true; return; } } + break; + + case Operation.HIGHER: + for (int i = 0; i < Tiles.GetLength(1); i++) { if (Tiles[1, i] == false) { Tiles[1, i] = true; return; } } + break; + + case Operation.SUBTRACTION: + for (int i = 0; i < Tiles.GetLength(1); i++) { if (Tiles[2, i] == false) { Tiles[2, i] = true; return; } } + break; + + case Operation.ADDITION: + for (int i = 0; i < Tiles.GetLength(1); i++) { if (Tiles[3, i] == false) { Tiles[3, i] = true; return; } } + break; + + case Operation.MULTIPLICATION: + for (int i = 0; i < Tiles.GetLength(1); i++) { if (Tiles[4, i] == false) { Tiles[4, i] = true; return; } } + break; + + default: + return; + } + } + + } +} diff --git a/source/Trek-12/Models/Pion.cs b/source/Trek-12/Models/Pion.cs new file mode 100644 index 0000000..6e34836 --- /dev/null +++ b/source/Trek-12/Models/Pion.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Models +{ + public class Pion + { + public Pion(Position pos) + { + Position = pos; + } + public Position Position { get; set; } + public bool Select { get; set; } + + public override string ToString() + { + return $"{Select}"; } + } +} diff --git a/source/Trek-12/Models/Position.cs b/source/Trek-12/Models/Position.cs new file mode 100644 index 0000000..44f47b8 --- /dev/null +++ b/source/Trek-12/Models/Position.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Models +{ + public class Position + { + public Position(int x, int y) + { + X = x; + Y = y; + } + + public int X { get; set; } + public int Y { get; set; } + + public override string ToString() + { + return $"{X} {Y}"; + } + } +}