diff --git a/CheckersCheckpoint/.vscode/launch.json b/CheckersCheckpoint/.vscode/launch.json new file mode 100644 index 00000000..0e2310de --- /dev/null +++ b/CheckersCheckpoint/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/CheckersCheckpoint.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/CheckersCheckpoint/.vscode/tasks.json b/CheckersCheckpoint/.vscode/tasks.json new file mode 100644 index 00000000..c894cb0c --- /dev/null +++ b/CheckersCheckpoint/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/CheckersCheckpoint.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/CheckersCheckpoint/Board.cs b/CheckersCheckpoint/Board.cs new file mode 100644 index 00000000..917421dc --- /dev/null +++ b/CheckersCheckpoint/Board.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace CheckersCheckpoint +{ + public class Board + { + public string[][] grid; + public List checkers; + + public Board() + { + this.Checkers = new List(); + this.CreateBoard(); + return; + } + public string[][] Grid { get; set; } + public List Checkers { get; set; } + + + public void CreateBoard() + { + this.Grid = new string[][] + { + new string[] {" ", " ", " ", " ", " ", " ", " ", " "}, + new string[] {" ", " ", " ", " ", " ", " ", " ", " "}, + new string[] {" ", " ", " ", " ", " ", " ", " ", " "}, + new string[] {" ", " ", " ", " ", " ", " ", " ", " "}, + new string[] {" ", " ", " ", " ", " ", " ", " ", " "}, + new string[] {" ", " ", " ", " ", " ", " ", " ", " "}, + new string[] {" ", " ", " ", " ", " ", " ", " ", " "}, + new string[] {" ", " ", " ", " ", " ", " ", " ", " "}, + }; + return; + } + + + public void GenerateCheckers() + { + int[][] whitePositions = new int[][] + { + new int[] { 0, 1 }, new int[] { 0, 3 }, new int[] { 0, 5 }, new int[] { 0, 7 }, + new int[] { 1, 0 }, new int[] { 1, 2 }, new int[] { 1, 4 }, new int[] { 1, 6 }, + new int[] { 2, 1 }, new int [] { 2, 3 }, new int[] { 2, 5 }, new int[] { 2, 7} + }; + + int[][] blackPositions = new int[][] + { + new int[] { 5, 0 }, new int[] { 5, 2 }, new int[] { 5, 4 }, new int[] { 5, 6 }, + new int[] { 6, 1 }, new int[] { 6, 3 }, new int[] { 6, 5 }, new int[] { 6, 7 }, + new int[] { 7, 0 }, new int[] { 7, 2 }, new int [] { 7, 4 }, new int[] { 7, 6 } + }; + + for (int i = 0; i < 12; i++) + + { + Checker white = new Checker("white", whitePositions[i]); + Checker black = new Checker("black", blackPositions[i]); + Checkers.Add(white); + Checkers.Add(black); + } + return; + } + + + + public void PlaceCheckers() + { + foreach (var checker in Checkers) + { + ; + this.Grid[checker.Position[0]][checker.Position[1]] = checker.Symbol; + } + return; + } + + + public void DrawBoard() + { + CreateBoard(); + PlaceCheckers(); + Console.WriteLine(" 0 1 2 3 4 5 6 7 "); + Console.OutputEncoding = System.Text.Encoding.UTF8; + for (int i = 0; i < 8; i++) + { + Console.WriteLine(i + " " + String.Join(" ", this.Grid[i])); + } + return; + } + + + public Checker SelectChecker(int row, int column) + { + return Checkers.Find(x => x.Position.SequenceEqual(new List { row, column })); + } + + + public void RemoveChecker(Checker checker) + { + Checkers.Remove(checker); + return; + } + + + public bool CheckForWin() + { + return Checkers.All(x => x.Color == "white") || !Checkers.Exists(x => x.Color == "white"); + } + } +} \ No newline at end of file diff --git a/CheckersCheckpoint/Checker.cs b/CheckersCheckpoint/Checker.cs new file mode 100644 index 00000000..6b687ce0 --- /dev/null +++ b/CheckersCheckpoint/Checker.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace CheckersCheckpoint +{ + public class Checker + { + public string symbol; + public int[] position; + public string color; + + + public Checker(string color, int[] position) + { + int circleId; + + if (color == "white") + { + circleId = int.Parse("25CE", System.Globalization.NumberStyles.HexNumber); + Color = "white"; + } + else + { + circleId = int.Parse("25C9", System.Globalization.NumberStyles.HexNumber); + Color = "black"; + } + this.Symbol = char.ConvertFromUtf32(circleId); + this.Position = position; + } + + public string Symbol + { + get; + set; + } + + public int[] Position + { + get; + set; + } + + public string Color + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CheckersCheckpoint/CheckersCheckpoint.csproj b/CheckersCheckpoint/CheckersCheckpoint.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/CheckersCheckpoint/CheckersCheckpoint.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + diff --git a/CheckersCheckpoint/Game.cs b/CheckersCheckpoint/Game.cs new file mode 100644 index 00000000..27da0253 --- /dev/null +++ b/CheckersCheckpoint/Game.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace CheckersCheckpoint +{ + public class Game + { + public Game() + { + Board board = new Board(); + board.GenerateCheckers(); + board.DrawBoard(); + + Console.WriteLine("\nIf you want to move a checker one space diagonally forward, enter 'move'."); + Console.WriteLine("\nIf a jump is available for one of your checker, you must enter 'jump'."); + + string choice = Console.ReadLine(); + + do + { + switch (choice) + { + case "move": + + Console.WriteLine("Enter checker Row to move:"); + int row = int.Parse(Console.ReadLine()); + Console.WriteLine("Enter checker Column:"); + int column = int.Parse(Console.ReadLine()); + + if (board.SelectChecker(row, column) != null) + { + Checker checker = board.SelectChecker(row, column); + Console.WriteLine("Move to which Row: "); + int newRow = int.Parse(Console.ReadLine()); + Console.WriteLine("Move to which Column: "); + int newColumn = int.Parse(Console.ReadLine()); + checker.Position = new int[] { newRow, newColumn }; + board.DrawBoard(); + } + else + { + Console.WriteLine("Invalid input"); + Console.WriteLine("Enter a valid checker Row:"); + row = int.Parse(Console.ReadLine()); + Console.WriteLine("Enter a valid checker Column:"); + column = int.Parse(Console.ReadLine()); + } + break; + + case "jump": + + Console.WriteLine("Select checker Row to remove:"); + int removeRow = int.Parse(Console.ReadLine()); + Console.WriteLine("Select checker Column to remove:"); + int removeColumn = int.Parse(Console.ReadLine()); + Checker changeChecker = board.SelectChecker(removeRow, removeColumn); + board.RemoveChecker(changeChecker); + board.DrawBoard(); + break; + + default: + + Console.WriteLine("Invalid input."); + break; + } + } + while (board.CheckForWin() != true); + } + } +} \ No newline at end of file diff --git a/CheckersCheckpoint/Program.cs b/CheckersCheckpoint/Program.cs new file mode 100644 index 00000000..6b7c027e --- /dev/null +++ b/CheckersCheckpoint/Program.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace CheckersCheckpoint +{ + public class Program + { + public static void Main(string[] args) + { + new Game(); + } + + } +} \ No newline at end of file diff --git a/CheckersCheckpoint/bash.exe.stackdump b/CheckersCheckpoint/bash.exe.stackdump new file mode 100644 index 00000000..4bc86685 --- /dev/null +++ b/CheckersCheckpoint/bash.exe.stackdump @@ -0,0 +1,16 @@ +Stack trace: +Frame Function Args +00180328AF0 0018006021E (00180247D00, 001802340B9, 00000000058, 000FFFFB740) +00180328AF0 00180048859 (00180236765, 00100000000, 00000000000, 00000000001) +00180328AF0 00180048892 (00000000000, 00000000000, 00000000058, 00180328950) +00180328AF0 0018006C179 (0000000000A, 00000000000, 0000000000A, 00000000000) +00180328AF0 0018006C342 (00000000003, 00000000000, 00180044EEF, 000FFFFCB30) +00000000000 0018006D3A8 (0000000000D, 000FFFFC920, 001800E4CF6, 000FFFFC920) +00000000000 00180058816 (000FFFF0000, 00000000000, 00000000000, 006FFFFFFFF) +00000000000 001800590A9 (000FFFFCAF0, 00600040000, 00000000000, 000FFFFCB80) +00180325CF8 001800595BA (001800C0322, 00000000000, 00000000000, 00000000000) +000FFFFCCD0 00180059937 (000FFFFCDF0, 000FFFFCCD0, FFFFFFFFFFFFFFD1, 00000000000) +000FFFFCCD0 00180048FE1 (00000000000, 00000000000, 00000000000, 00000000000) +00000000000 00180047963 (00000000000, 00000000000, 00000000000, 00000000000) +000FFFFFFF0 00180047A14 (00000000000, 00000000000, 00000000000, 00000000000) +End of stack trace diff --git a/FizzBuzz/FizzBuzz.cs b/FizzBuzz/FizzBuzz.cs index 9246f703..27b1e5c1 100644 --- a/FizzBuzz/FizzBuzz.cs +++ b/FizzBuzz/FizzBuzz.cs @@ -1,4 +1,6 @@ using System; +using System.Linq; +using System.Collections.Generic; namespace FizzBuzz { @@ -6,7 +8,24 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + for (int i = 1; i < 100; i++) + { + if (i % 3 == 0) + { + Console.Write("FIZZ"); + } + if (i % 5 == 0) + { + Console.Write("BUZZ"); + } + if (i % 3 != 0 && i % 5 != 0) + { + Console.Write(i); + } + Console.Write("\n"); + } + // Enumerable.Range(1, 100).Select(n => new Dictionary + // { {15, "FizzBuzz"}, {3, "Fizz"}, {5, "Buzz"}, {1, n.ToString()} }.First(kv => n % kv.Key == 0).Value).ToList().ForEach(Console.WriteLine); } } } diff --git a/HelloWorld/.vscode/launch.json b/HelloWorld/.vscode/launch.json new file mode 100644 index 00000000..6fcc71fd --- /dev/null +++ b/HelloWorld/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/HelloWorld.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/HelloWorld/.vscode/tasks.json b/HelloWorld/.vscode/tasks.json new file mode 100644 index 00000000..7cf275a8 --- /dev/null +++ b/HelloWorld/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/HelloWorld.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/HelloWorld/HelloWorld.cs b/HelloWorld/HelloWorld.cs index 8168c805..10c84062 100644 --- a/HelloWorld/HelloWorld.cs +++ b/HelloWorld/HelloWorld.cs @@ -6,7 +6,19 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + string name = ""; + int age = 0; + int year = 0; + + Console.WriteLine("Please enter your name: "); + name = Console.ReadLine(); + Console.WriteLine("Please enter your age: "); + age = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Please enter the year: "); + year = Convert.ToInt32(Console.ReadLine()); + + Console.WriteLine("Hello! My name is {0} and I am {1} years old. I was born in {2}.", name, age, year-age); + } } } diff --git a/NewCheckers/.vscode/launch.json b/NewCheckers/.vscode/launch.json new file mode 100644 index 00000000..d3ae507e --- /dev/null +++ b/NewCheckers/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/NewCheckers.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/NewCheckers/.vscode/tasks.json b/NewCheckers/.vscode/tasks.json new file mode 100644 index 00000000..ab83386f --- /dev/null +++ b/NewCheckers/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/NewCheckers.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/NewCheckers/Board.cs b/NewCheckers/Board.cs new file mode 100644 index 00000000..4fc5b7ce --- /dev/null +++ b/NewCheckers/Board.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Threading; + +namespace NewCheckers +{ + public class Board + { + public Dictionary pieces { get; set; } + + public Board() + { + pieces = new Dictionary(); + for (int i = 0; i < 8; i++) + { + for (int j = 0; j < 8; j++) + { + Coordinates cord = new Coordinates(i, j); + Checker check = null; + switch (i) + { + case 0: + if (j % 2 == 0 || j == 0) + { + check = new Checker("black"); + pieces.Add(cord, check); + } + else + { + pieces.Add(cord, null); + } + break; + case 1: + if (j % 2 == 0 || j == 0) + { + pieces.Add(cord, null); + } + else + { + check = new Checker("black"); + pieces.Add(cord, check); + } + break; + case 2: + if (j % 2 == 0 || j == 0) + { + check = new Checker("black"); + pieces.Add(cord, check); + } + else + { + pieces.Add(cord, null); + } + break; + case 5: + if (j % 2 == 0 || j == 0) + { + pieces.Add(cord, null); + } + else + { + check = new Checker("white"); + pieces.Add(cord, check); + } + break; + case 6: + if (j % 2 == 0 || j == 0) + { + check = new Checker("white"); + pieces.Add(cord, check); + } + else + { + pieces.Add(cord, null); + } + break; + case 7: + if (j % 2 == 0 || j == 0) + { + pieces.Add(cord, null); + } + else + { + check = new Checker("white"); + pieces.Add(cord, check); + } + break; + default: + pieces.Add(cord, null); + break; + } + } + } + } + } +} + diff --git a/NewCheckers/CheckLanding.cs b/NewCheckers/CheckLanding.cs new file mode 100644 index 00000000..f692633f --- /dev/null +++ b/NewCheckers/CheckLanding.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; + +namespace NewCheckers +{ + public class CheckLanding + { + public Coordinates Remove { get; set; } + public bool Jumped { get; set; } = false; + + + public CheckLanding() + { + Jumped = false; + } + public bool Run(Coordinates from, Coordinates to, Dictionary curBoard) + { + int x = from.X; + int y = from.Y; + int toX = to.X; + int toY = to.Y; + + List possibles = new List(); + possibles.Add(new Coordinates(x - 1, y - 1)); + possibles.Add(new Coordinates(x - 2, y - 2)); + possibles.Add(new Coordinates(x + 1, y + 1)); + possibles.Add(new Coordinates(x + 2, y + 2)); + possibles.Add(new Coordinates(x - 1, y + 1)); + possibles.Add(new Coordinates(x - 2, y + 2)); + possibles.Add(new Coordinates(x + 1, y - 1)); + possibles.Add(new Coordinates(x + 2, y - 2)); + + bool isValidLanding = false; + bool twoSpaces = false; + + foreach (var item in possibles) + { + if (item.X == to.X && item.Y == to.Y) + { + isValidLanding = true; + if (item.X - 2 == x || item.X + 2 == x) + { + twoSpaces = true; + } + } + } + Checker occupied; + if (curBoard.TryGetValue(to, out occupied)) + { + if (occupied != null) + { + isValidLanding = false; + } + } + + if (isValidLanding) + { + if (twoSpaces) + { + if (toX - 2 == x) + { + if (toY - 2 == y) + { + Jumped = true; + Remove = new Coordinates(toX - 1, toY - 1); + } + else + { + Jumped = true; + Remove = new Coordinates(toX - 1, toY + 1); + } + } + else if (toX + 2 == x) + { + if (toY - 2 == y) + { + Jumped = true; + Remove = new Coordinates(toX + 1, toY - 1); + } + else + { + Jumped = true; + Remove = new Coordinates(toX + 1, toY + 1); + } + } + else + { + twoSpaces = true; + Jumped = false; + } + } + + } + bool returnMe = isValidLanding ? true : false; + + return returnMe; + } + } +} \ No newline at end of file diff --git a/NewCheckers/Checker.cs b/NewCheckers/Checker.cs new file mode 100644 index 00000000..a4bfb23b --- /dev/null +++ b/NewCheckers/Checker.cs @@ -0,0 +1,31 @@ +using System; + +namespace NewCheckers +{ + public class Checker + { + public string Color { get; private set; } + public string ColorAbs { get; private set; } + public bool King { get; private set; } + public Checker(string color) + { + int circleId; + + if (color == "white") + { + circleId = int.Parse("25CE", System.Globalization.NumberStyles.HexNumber); + ColorAbs = "white"; + } + else + { + circleId = int.Parse("25CF", System.Globalization.NumberStyles.HexNumber); + ColorAbs = "black"; + } + this.Color = char.ConvertFromUtf32(circleId); + } + public void MakeKing() + { + this.King = true; + } + } +} diff --git a/NewCheckers/Coordinates.cs b/NewCheckers/Coordinates.cs new file mode 100644 index 00000000..ff0b1818 --- /dev/null +++ b/NewCheckers/Coordinates.cs @@ -0,0 +1,15 @@ +using System; + +namespace NewCheckers +{ + public struct Coordinates + { + public int X { get; private set; } + public int Y { get; private set; } + public Coordinates(int x, int y) + { + this.X = x; + this.Y = y; + } + } +} diff --git a/NewCheckers/CreateCheckers.cs b/NewCheckers/CreateCheckers.cs new file mode 100644 index 00000000..5ec70267 --- /dev/null +++ b/NewCheckers/CreateCheckers.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; + +namespace NewCheckers +{ + class CreateCheckers + { + Dictionary initialSetup = new Dictionary(); + //public Dictionary InitialCheckers() + //{ + + //} + } +} \ No newline at end of file diff --git a/NewCheckers/Display.cs b/NewCheckers/Display.cs new file mode 100644 index 00000000..ed37e5ca --- /dev/null +++ b/NewCheckers/Display.cs @@ -0,0 +1,337 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NewCheckers +{ + public class Display + { + public Dictionary pieces { get; set; } + private int index = 0; + private Boolean Second = false; + private Coordinates cordsPrior; + public Display(Dictionary board) + { + pieces = new Dictionary(); + Coordinates cord; + for (int i = 0; i < 8; i++) + { + for (int j = 0; j < 8; j++) + { + cord = new Coordinates(i, j); + Checker c; + if (board.TryGetValue(cord, out c)) + { + if (c != null) + { + this.pieces.Add(cord, c.Color); + } + } + else + { + this.pieces.Add(cord, " "); + } + } + } + } + public int ChooseX(int player, string one, string two)//ChooseX + { + if (one != null && two != null) + { + int x = Convert.ToInt32(one); + int y = Convert.ToInt32(two); + cordsPrior = new Coordinates(x, y); + string testMe = ""; + if (pieces.TryGetValue(cordsPrior, out testMe)) + { + Second = testMe == null ? false : true; + } + } + Console.Clear(); + Coordinates cord; + string returnMe = ""; + Console.CursorVisible = false; + while (returnMe == "") + { + Console.WriteLine("Player " + player + " Choose A Row."); + Console.WriteLine(); + for (int i = 0; i < 8; i++) + { + if (index == i) + { + Console.BackgroundColor = ConsoleColor.Black; + Console.ForegroundColor = ConsoleColor.Green; + Console.Write(i); + Console.Write(" "); + } + else + { + Console.BackgroundColor = ConsoleColor.Black; + Console.ForegroundColor = ConsoleColor.White; + Console.Write(i); + Console.Write(" "); + } + for (int j = 0; j < 8; j++) + { + cord = new Coordinates(i, j); + if (i == 0 || i % 2 == 0) + { + if (j == 0 || j % 2 == 0) + { + Console.BackgroundColor = ConsoleColor.White; + if (Second) + { + if (cord.X == cordsPrior.X && cord.Y == cordsPrior.Y) + { + Console.BackgroundColor = ConsoleColor.Blue; + } + } + } + else + { + Console.BackgroundColor = ConsoleColor.Black; + if (Second) + { + if (cord.X == cordsPrior.X && cord.Y == cordsPrior.Y) + { + Console.BackgroundColor = ConsoleColor.Blue; + } + } + } + } + else + { + if (j == 0 || j % 2 == 0) + { + Console.BackgroundColor = ConsoleColor.Black; + if (Second) + { + if (cord.X == cordsPrior.X && cord.Y == cordsPrior.Y) + { + Console.BackgroundColor = ConsoleColor.Blue; + } + } + } + else + { + Console.BackgroundColor = ConsoleColor.White; + if (Second) + { + if (cord.X == cordsPrior.X && cord.Y == cordsPrior.Y) + { + Console.BackgroundColor = ConsoleColor.Blue; + } + } + } + } + string value = ""; + if (pieces.TryGetValue(cord, out value)) + { + Console.OutputEncoding = System.Text.Encoding.UTF8; + Console.Write(" "); + if (value == char.ConvertFromUtf32(int.Parse("25CE", System.Globalization.NumberStyles.HexNumber))) + { + value = char.ConvertFromUtf32(int.Parse("25CF", System.Globalization.NumberStyles.HexNumber)); + Console.ForegroundColor = ConsoleColor.Red; + + Console.Write(value); + Console.Write(" "); + } + else + { + Console.ForegroundColor = ConsoleColor.Black; + Console.Write(value); + Console.Write(" "); + } + } + else + { + Console.Write(" "); + } + Console.ResetColor(); + } + Console.WriteLine(); + } + List items = new List { "0", "1", "2", "3", "4", "5", "6", "7" }; + returnMe = MenuControllerX(items); + } + index = 0; + return Convert.ToInt32(returnMe); + } + private string MenuControllerX(List items) + { + ConsoleKeyInfo userInput = Console.ReadKey(); + + if (userInput.Key == ConsoleKey.DownArrow) + { + index = index == items.Count - 1 ? 0 : index + 1; + } + else if (userInput.Key == ConsoleKey.UpArrow) + { + index = index <= 0 ? items.Count - 1 : index - 1; + } + else if (userInput.Key == ConsoleKey.Enter) + { + return items[index]; + } + Console.Clear(); + return ""; + } + public int ChooseY(int player, int x, string one, string two)//PickY + { + if (one != null && two != null) + { + int z = Convert.ToInt32(one); + int y = Convert.ToInt32(two); + cordsPrior = new Coordinates(z, y); + string testMe = ""; + if (pieces.TryGetValue(cordsPrior, out testMe)) + { + Second = testMe == null ? false : true; + } + } + Console.Clear(); + Coordinates cord; + string returnMe = ""; + Console.CursorVisible = false; + while (returnMe == "") + { + Console.WriteLine("Player " + player + " Choose A Row."); + Console.WriteLine(); + for (int i = 0; i < 8; i++) + { + for (int j = 0; j < 8; j++) + { + cord = new Coordinates(i, j); + + if (i == 0 || i % 2 == 0) + { + if (j == 0 || j % 2 == 0) + { + Console.BackgroundColor = ConsoleColor.White; + if (Second) + { + if (cord.X == cordsPrior.X && cord.Y == cordsPrior.Y) + { + Console.BackgroundColor = ConsoleColor.Blue; + } + } + } + else + { + Console.BackgroundColor = ConsoleColor.Black; + if (Second) + { + if (cord.X == cordsPrior.X && cord.Y == cordsPrior.Y) + { + Console.BackgroundColor = ConsoleColor.Blue; + } + } + } + if (i == x && j == index) + { + Console.BackgroundColor = ConsoleColor.Green; + } + } + else + { + if (j == 0 || j % 2 == 0) + { + Console.BackgroundColor = ConsoleColor.Black; + if (Second) + { + if (cord.X == cordsPrior.X && cord.Y == cordsPrior.Y) + { + Console.BackgroundColor = ConsoleColor.Blue; + } + } + } + else + { + Console.BackgroundColor = ConsoleColor.White; + if (Second) + { + if (cord.X == cordsPrior.X && cord.Y == cordsPrior.Y) + { + Console.BackgroundColor = ConsoleColor.Blue; + } + } + } + if (i == x && j == index) + { + Console.BackgroundColor = ConsoleColor.Green; + } + } + string value = ""; + if (pieces.TryGetValue(cord, out value)) + { + Console.OutputEncoding = System.Text.Encoding.UTF8; + Console.Write(" "); + if (value == char.ConvertFromUtf32(int.Parse("25CE", System.Globalization.NumberStyles.HexNumber))) + { + value = char.ConvertFromUtf32(int.Parse("25CF", System.Globalization.NumberStyles.HexNumber)); + Console.ForegroundColor = ConsoleColor.Red; + Console.Write(value); + Console.Write(" "); + } + else + { + Console.ForegroundColor = ConsoleColor.Black; + Console.Write(value); + Console.Write(" "); + } + } + else + { + Console.Write(" "); + } + Console.ResetColor(); + } + Console.WriteLine(); + } + List items = new List { "0", "1", "2", "3", "4", "5", "6", "7" }; + for (int i = 0; i < items.Count; i++) + { + if (index == i) + { + Console.BackgroundColor = ConsoleColor.Black; + Console.ForegroundColor = ConsoleColor.Green; + Console.Write(" "); + Console.Write(items[i]); + Console.Write(" "); + } + else + { + Console.BackgroundColor = ConsoleColor.Black; + Console.ForegroundColor = ConsoleColor.White; + Console.Write(" "); + Console.Write(items[i]); + Console.Write(" "); + } + } + returnMe = MenuControllerY(items); + } + return Convert.ToInt32(returnMe); + } + private string MenuControllerY(List items) + { + ConsoleKeyInfo userInput = Console.ReadKey(); + + if (userInput.Key == ConsoleKey.RightArrow) + { + index = index == items.Count - 1 ? 0 : index + 1; + } + else if (userInput.Key == ConsoleKey.LeftArrow) + { + index = index <= 0 ? items.Count - 1 : index - 1; + } + else if (userInput.Key == ConsoleKey.Enter) + { + return items[index]; + } + Console.Clear(); + return ""; + } + + } +} diff --git a/NewCheckers/Game.cs b/NewCheckers/Game.cs new file mode 100644 index 00000000..e17f3317 --- /dev/null +++ b/NewCheckers/Game.cs @@ -0,0 +1,67 @@ +using System; + +namespace NewCheckers +{ + public class Game + { + //request both moves controle board + Board CurrentBoard; + public Game() + { + CurrentBoard = new Board(); + } + public int White = 0; + public int Black = 0; + public void Run() + { + int turn = 1; + bool GameOver = false; + int Winner; + while (!GameOver) + { + Select Choose = new Select(turn, CurrentBoard.pieces); + Coordinates moveFrom = Choose.From(); + Coordinates moveTo = Choose.To(moveFrom); + bool valid = Choose.CheckValidity(moveFrom, moveTo); + + if (valid) + { + CurrentBoard.pieces[moveTo] = CurrentBoard.pieces[moveFrom]; + CurrentBoard.pieces[moveFrom] = null; + if (moveTo.X == 0 && turn == 1) + { + this.CurrentBoard.pieces[moveTo].MakeKing(); + } + if (moveTo.X == 7 && turn == 2) + { + this.CurrentBoard.pieces[moveTo].MakeKing(); + } + if (Choose.Jumped == true) + { + bool addPoint = CurrentBoard.pieces[Choose.Remove].ColorAbs == "white" ? true : false; + this.CurrentBoard.pieces[Choose.Remove] = null; + if (addPoint) + { + this.White++; + } + else + { + this.Black++; + } + } + + turn = turn == 1 ? 2 : 1; + } + + GameOver = White == 12 || Black == 12 ? true : false; + if (GameOver) + { + Winner = White == 12 ? 1 : 2; + } + } + } + } +} +/*Display display = new Display(CurrentBoard.pieces); + int one = display.ChooseX(1); + int two = display.ChooseY(1, one); */ diff --git a/NewCheckers/IsValid.cs b/NewCheckers/IsValid.cs new file mode 100644 index 00000000..bdb5a0c9 --- /dev/null +++ b/NewCheckers/IsValid.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; + +namespace NewCheckers +{ + public class IsValid + { + private int Turn; + private Dictionary CurBoard; + private Coordinates From; + private Coordinates To; + public bool Valid = false; + public Coordinates Remove; + public bool Jumped = false; + public IsValid(int turn, Dictionary curBoard, Coordinates from, Coordinates to) + { + this.CurBoard = curBoard; + this.Turn = turn; + this.From = from; + this.To = to; + } + public bool Run() + { + bool isFromValid = false; + bool isToValid = false; + isFromValid = CheckFrom(); + isToValid = CheckTo(); + this.Valid = isFromValid && isToValid ? true : false; + return Valid; + } + private bool CheckFrom() + { + bool from; + if (Turn == 1 && CurBoard[From] != null && CurBoard[From].ColorAbs == "white") + { + from = true; + } + else if (Turn == 2 && CurBoard[From] != null && CurBoard[From].ColorAbs == "black") + { + from = true; + } + else + { + from = false; + } + return from; + } + private bool CheckTo() + { + bool to = false; + CheckLanding land = new CheckLanding(); + to = land.Run(From, To, CurBoard); + if (land.Jumped) + { + this.Remove = land.Remove; + this.Jumped = true; + } + if (Turn == 1 && (From.X - To.X) < 0) + { + Checker tryMe; + if (CurBoard.TryGetValue(From, out tryMe)) + { + if (tryMe != null) + { + if (!tryMe.King) + { + to = false; + } + } + } + else + { + to = false; + } + } + if (Turn == 2 && (To.X - From.X) < 0) + { + Checker tryMe; + if (CurBoard.TryGetValue(From, out tryMe)) + { + if (tryMe != null && !tryMe.King) + if (tryMe != null) + { + if (!tryMe.King) + { + to = false; + } + } + } + else + { + to = false; + } + } + return to; + } + + } +} diff --git a/NewCheckers/NewCheckers.csproj b/NewCheckers/NewCheckers.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/NewCheckers/NewCheckers.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + diff --git a/NewCheckers/Program.cs b/NewCheckers/Program.cs new file mode 100644 index 00000000..99a62ada --- /dev/null +++ b/NewCheckers/Program.cs @@ -0,0 +1,13 @@ +using System; + +namespace NewCheckers +{ + class Program + { + static void Main(string[] args) + { + Game game = new Game(); + game.Run(); + } + } +} diff --git a/NewCheckers/Select.cs b/NewCheckers/Select.cs new file mode 100644 index 00000000..05f35731 --- /dev/null +++ b/NewCheckers/Select.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Threading; + +namespace NewCheckers +{ + public class Select + { + private Dictionary CurBoard; + private int Turn; + public bool Jumped = false; + public Coordinates Remove; + public Select(int currentTurn, Dictionary CurrentBoard) + { + CurBoard = CurrentBoard; + Turn = currentTurn; + } + public Coordinates From() + { + Display display = new Display(CurBoard); + int row = display.ChooseX(Turn, null, null); + int column = display.ChooseY(Turn, row, null, null); + return new Coordinates(row, column); + } + public Coordinates To(Coordinates old) + { + string x = old.X.ToString(); + string y = old.Y.ToString(); + Display display = new Display(CurBoard); + int row = display.ChooseX(Turn, x, y); + int column = display.ChooseY(Turn, row, x, y); + return new Coordinates(row, column); + } + public bool CheckValidity(Coordinates from, Coordinates to) + { + IsValid isValid = new IsValid(Turn, CurBoard, from, to); + bool valid = isValid.Run(); + if (isValid.Jumped) + { + this.Jumped = true; + this.Remove = isValid.Remove; + } + return valid; + } + } +} \ No newline at end of file diff --git a/PigLatin/.vscode/launch.json b/PigLatin/.vscode/launch.json new file mode 100644 index 00000000..3cecefcf --- /dev/null +++ b/PigLatin/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/PigLatin.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/PigLatin/.vscode/tasks.json b/PigLatin/.vscode/tasks.json new file mode 100644 index 00000000..a705ed07 --- /dev/null +++ b/PigLatin/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/PigLatin.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index 702647dd..c05fcd1b 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -7,15 +7,127 @@ class Program public static void Main() { // your code goes here + Console.WriteLine("enter a word to translate "); + string userInput = Console.ReadLine(); + string newWord = TranslateWord(userInput); + string VowelNewWord = TranslateWordVowel(userInput); + string startsWithVowelNewWord = startsWithVowel(userInput); + string lowercaseNewWord = makeLowerCase(userInput); + Console.Write("heres your word translated to piglatin: "); + Console.WriteLine(newWord); + Console.Write("heres your word translated at the first vowel to piglatin: "); + Console.WriteLine(VowelNewWord); + + Console.Write("heres your word translated to piglatin unless it starts with a vowel: "); + Console.WriteLine(startsWithVowelNewWord); + + Console.Write("heres your word translated to piglatin and made lowercase: "); + Console.WriteLine(lowercaseNewWord); + Console.WriteLine(""); + + Console.WriteLine("Let's try a whole sentence!"); + string userInputSentence = Console.ReadLine(); + string translatedSentence = moreWords(userInputSentence); + Console.WriteLine(translatedSentence); + Console.Write("oops let me fix that punctuation"); + for (int i = 0; i < 5; i++) + { + System.Threading.Thread.Sleep(1000); + Console.Write("."); + } + Console.WriteLine(""); + string fixTranslation = fixPunctuation(translatedSentence); + Console.WriteLine(fixTranslation); // leave this command at the end so your program does not close automatically Console.ReadLine(); } - + public static string TranslateWord(string word) + { + string firstLetter = word.Substring(0, 1); + string restWord = word.Substring(1); + string translatedWord = (restWord + firstLetter + "ay"); + return translatedWord; + } + + public static string TranslateWordVowel(string word) { // your code goes here - return word; + int firstVowelIndex = word.IndexOfAny(new char[] { 'a', 'e', 'i', 'o', 'u', 'y' }); + string firstPart = word.Substring(0, firstVowelIndex); + string secondPart = word.Substring(firstVowelIndex); + string translatedWord = (secondPart + firstPart + "ay"); + + return translatedWord; + } + + public static string startsWithVowel(string word) + { + // your code goes here + int firstVowelIndex = word.IndexOfAny(new char[] { 'a', 'e', 'i', 'o', 'u', 'y' }); + string last = word.Substring(0, 1); + string first = word.Substring(1); + if (firstVowelIndex == 0) + { + + string translatedWord = (last + first + "yay"); + + return translatedWord; + } + else + { + string notAVowel = (first + last + "ay (try a word that starts with a vowel!)"); + return notAVowel; + } + + } + public static string makeLowerCase(string word) + { + string convertLower = word.ToLower(); + string firstLetter = convertLower.Substring(0, 1); + string restWord = convertLower.Substring(1); + string translatedWord = (restWord + firstLetter + "ay (try a word that has differant cased letters!)"); + return translatedWord; + } + public static string moreWords(string words) + { + string[] allWords = words.Split(' '); + string[] translatedWords = new string[allWords.Length]; + for (int i = 0; i < allWords.Length; i++) + { + string firstLetter = allWords[i].Substring(0, 1); + string restWord = allWords[i].Substring(1); + translatedWords[i] = (restWord + firstLetter + "ay"); + } + string translatedString = String.Join(" ", translatedWords); + return translatedString; + } + public static string fixPunctuation(string words) + { + string[] allWords = words.Split(' '); + string[] correctedWords = new string[allWords.Length]; + for (int i = 0; i < allWords.Length; i++) + { + int findPunctuation = allWords[i].IndexOfAny(new char[] { '?', '.', '!', ',' }); + if (findPunctuation > 0) + { + string firstPart = allWords[i].Substring(0, findPunctuation); + string secondPartIncorrect = allWords[i].Substring(findPunctuation); + string secondPartFirst = secondPartIncorrect.Substring(0, 1); + string secondPartlast = secondPartIncorrect.Substring(1); + string secondPart = secondPartlast + secondPartFirst; + correctedWords[i] = (firstPart + secondPart); + } + else + { + correctedWords[i] = allWords[i]; + } + } + string translatedString = String.Join(" ", correctedWords); + return translatedString; } } } + + diff --git a/PigLatin/bash.exe.stackdump b/PigLatin/bash.exe.stackdump new file mode 100644 index 00000000..4bc86685 --- /dev/null +++ b/PigLatin/bash.exe.stackdump @@ -0,0 +1,16 @@ +Stack trace: +Frame Function Args +00180328AF0 0018006021E (00180247D00, 001802340B9, 00000000058, 000FFFFB740) +00180328AF0 00180048859 (00180236765, 00100000000, 00000000000, 00000000001) +00180328AF0 00180048892 (00000000000, 00000000000, 00000000058, 00180328950) +00180328AF0 0018006C179 (0000000000A, 00000000000, 0000000000A, 00000000000) +00180328AF0 0018006C342 (00000000003, 00000000000, 00180044EEF, 000FFFFCB30) +00000000000 0018006D3A8 (0000000000D, 000FFFFC920, 001800E4CF6, 000FFFFC920) +00000000000 00180058816 (000FFFF0000, 00000000000, 00000000000, 006FFFFFFFF) +00000000000 001800590A9 (000FFFFCAF0, 00600040000, 00000000000, 000FFFFCB80) +00180325CF8 001800595BA (001800C0322, 00000000000, 00000000000, 00000000000) +000FFFFCCD0 00180059937 (000FFFFCDF0, 000FFFFCCD0, FFFFFFFFFFFFFFD1, 00000000000) +000FFFFCCD0 00180048FE1 (00000000000, 00000000000, 00000000000, 00000000000) +00000000000 00180047963 (00000000000, 00000000000, 00000000000, 00000000000) +000FFFFFFF0 00180047A14 (00000000000, 00000000000, 00000000000, 00000000000) +End of stack trace diff --git a/Program.cs b/Program.cs new file mode 100644 index 00000000..d879ba8f --- /dev/null +++ b/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace csharp_workbook +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/RockPaperScissors/.vscode/launch.json b/RockPaperScissors/.vscode/launch.json new file mode 100644 index 00000000..5bb6f9ea --- /dev/null +++ b/RockPaperScissors/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/RockPaperScissors.dll", + "args": [], + "cwd": "${workspaceFolder}", + // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ,] +} \ No newline at end of file diff --git a/RockPaperScissors/.vscode/tasks.json b/RockPaperScissors/.vscode/tasks.json new file mode 100644 index 00000000..9cdb0334 --- /dev/null +++ b/RockPaperScissors/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/RockPaperScissors.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index 470ae756..dc58b15b 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -6,20 +6,94 @@ class Program { public static void Main() { - Console.WriteLine("Enter hand 1:"); - string hand1 = Console.ReadLine().ToLower(); - Console.WriteLine("Enter hand 2:"); - string hand2 = Console.ReadLine().ToLower(); - Console.WriteLine(CompareHands(hand1, hand2)); + int firstPlayer = 0; + int secondPlayer = 0; + bool keepPlaying = true; + bool playAgain = true; + while (keepPlaying == true) + { + while (playAgain == true) + { + Console.Clear(); + Console.WriteLine("Enter hand 1:"); + string hand1 = Console.ReadLine().ToLower(); + Console.WriteLine("Enter hand 2 or c for a computer player"); + string hand2 = Console.ReadLine().ToLower(); + string showWinner = (CompareHands(hand1, hand2)); + string[] splitResults = showWinner.Split('*'); + string winnerText = splitResults[0]; + int winnerAdd = Convert.ToInt32(splitResults[1]); + Console.WriteLine(winnerText); + if (winnerAdd == 1) + { + firstPlayer++; + } + else if (winnerAdd == 2) + { + secondPlayer++; + } + Console.WriteLine("The score is {0} to {1}", firstPlayer, secondPlayer); + playAgain = false; + } + Console.WriteLine("Would you like to play again y/n"); + bool playingagain = (restartGame(Console.ReadLine())); + if (playingagain) + { + playAgain = true; + } + } // leave this command at the end so your program does not close automatically Console.ReadLine(); } - + private static readonly Random getrandom = new Random(); public static string CompareHands(string hand1, string hand2) { // Your code here - return hand1 + ' ' + hand2; + string hand2c = hand2; + string ifComputer = "Player 2"; + if (hand2 == "c") + { + int computer = getrandom.Next(1, 3); + string[] computerOptions = { "rock", "paper", "scissors" }; + hand2c = computerOptions[computer]; + ifComputer = "The computer"; + } + string winner = ""; + string addPoints = ""; + if (hand1 == hand2c) + { + winner = "It's a tie!"; + } + else if (hand1 == "rock" && hand2c != "paper") + { + winner = "Player One has won the game!*1"; + } + else if (hand1 == "scissors" && hand2c != "rock") + { + winner = "Player One has won the game!*1"; + } + else if (hand1 == "paper" && hand2c != "scissors") + { + winner = "Player One has won the game!*1"; + } + else + { + winner = ($"{ifComputer} has won the game!*2"); + } + return winner; + } + public static bool restartGame(string answer) + { + string play = answer.ToLower(); + if (play == "y" || play == "yes") + { + return true; + } + else + { + return false; + } } } } diff --git a/csharp-workbook.csproj b/csharp-workbook.csproj new file mode 100644 index 00000000..2bc70000 --- /dev/null +++ b/csharp-workbook.csproj @@ -0,0 +1,9 @@ + + + + Exe + netcoreapp2.2 + csharp_workbook + + + diff --git a/fileTreeBonus/.vscode/launch.json b/fileTreeBonus/.vscode/launch.json new file mode 100644 index 00000000..d7aba0dc --- /dev/null +++ b/fileTreeBonus/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/fileTreeBonus.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/fileTreeBonus/.vscode/tasks.json b/fileTreeBonus/.vscode/tasks.json new file mode 100644 index 00000000..26188ec8 --- /dev/null +++ b/fileTreeBonus/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/fileTreeBonus.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/fileTreeBonus/Program.cs b/fileTreeBonus/Program.cs new file mode 100644 index 00000000..5420dca7 --- /dev/null +++ b/fileTreeBonus/Program.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; + +namespace fileTreeBonus +{ + class Program + { + static void Main(string[] args) + + { + string my_path = @"C:\Users\MyPIDHere\SomeFolder\SomeSubFolder\some_document.txt"; + var path_parts = my_path.Split(new char[] { '\\' }); + List output_parts = new List(); + for (int i = 0; i < path_parts.Length; i++) + { + string indent = new String(' ', i); + string indentChar = ""; + if (i > 0) + { + indentChar = indent + "└──"; + indent = indent + indent; + } + output_parts.Add(String.Format("{0} {1} {2}", indent, indentChar, path_parts[i])); + } + string tree = String.Join("\n", output_parts); + Console.Write(tree); + } + + } +} diff --git a/fileTreeBonus/fileTreeBonus.csproj b/fileTreeBonus/fileTreeBonus.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/fileTreeBonus/fileTreeBonus.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + diff --git a/guessingGame/.vscode/launch.json b/guessingGame/.vscode/launch.json new file mode 100644 index 00000000..1369ab24 --- /dev/null +++ b/guessingGame/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/guessingGame.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/guessingGame/.vscode/tasks.json b/guessingGame/.vscode/tasks.json new file mode 100644 index 00000000..360a95d7 --- /dev/null +++ b/guessingGame/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/guessingGame.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/guessingGame/Program.cs b/guessingGame/Program.cs new file mode 100644 index 00000000..050aff26 --- /dev/null +++ b/guessingGame/Program.cs @@ -0,0 +1,38 @@ +using System; + +namespace guessingGame +{ + class Program + { + private static readonly Random getrandom = new Random(); + static void Main(string[] args) + { + int computer = getrandom.Next(1, 10); + Console.WriteLine(computer); + bool win = false; + for (int i = 0; i < 4; i++) + { + Console.WriteLine("Guess a number between 1 and 10. You have 4 chances"); + int playerGuess = Convert.ToInt32(Console.ReadLine()); + if (playerGuess == computer) + { + Console.WriteLine("congratulations you guessed correct! The number was {0}", playerGuess); + win = true; + break; + } + else + { + Console.WriteLine("Guess Again!"); + } + } + if (win) + { + + } + else + { + Console.WriteLine("good attempt, but you dident guess the number"); + } + } + } +} diff --git a/guessingGame/guessingGame.csproj b/guessingGame/guessingGame.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/guessingGame/guessingGame.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + diff --git a/multithreading/.vscode/launch.json b/multithreading/.vscode/launch.json new file mode 100644 index 00000000..a01905f1 --- /dev/null +++ b/multithreading/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/multithreading.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/multithreading/.vscode/tasks.json b/multithreading/.vscode/tasks.json new file mode 100644 index 00000000..5ed1e266 --- /dev/null +++ b/multithreading/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/multithreading.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/multithreading/Program.cs b/multithreading/Program.cs new file mode 100644 index 00000000..814e42dd --- /dev/null +++ b/multithreading/Program.cs @@ -0,0 +1,94 @@ +using System; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Linq; + +namespace AsyncSort +{ + public class Program + { + public class Lists + { + public List less_than = new List(); + public List greater_than = new List(); + } + public class Objects + { + public List lists_objects = new List(); + } + public class Tasks + { + public List> task_list = new List>(); + } + public static void Main() + { + var value_to_sort = new List { 4, 5, 10, 12, 14, 20, 1, 205, 26, 31, 120, 2, 3, 72, 40, 100, 140 }; + Program start = new Program(); + string sorted_list = start.ReturnSortedValues(value_to_sort); + Console.WriteLine(sorted_list); + } + private string ReturnSortedValues(List numbers) + { + var sort_me = new Objects(); + var semi_sorted = new Objects(); + Lists starting_lists = new Lists(); + int i = 0; + int j = 0; + foreach (var num in numbers) + { + if (num <= numbers.Average()) + { + starting_lists.less_than[i] = num; + i++; + } + else + { + starting_lists.greater_than[j] = num; + i++; + } + } + sort_me.lists_objects[0] = starting_lists; + + while (sort_me.lists_objects.Count != numbers.Count / 2) + { + var return_tasks = Sorted(sort_me).Result; + foreach (var tsk in return_tasks.task_list) + { + semi_sorted.lists_objects.Add(tsk.Result); + } + + // foreach (var num in nums) + // { + // taskListGreater.Add(GreaterThanAverage(num, avg)); + // } + + // await Task.WhenAll(return_tasks); + // var sort = + // sort_me = sort; + } + + return "print this"; + } + + public static async Task> Sorted(Objects double_me) + { + var semi_sorted = new Objects(); + semi_sorted.lists_objects = double_me.lists_objects; + + var simplified = semi_sorted.lists_objects; + var task_list = new List>(); + List return_this = new List(); + for (int i = 0; i > semi_sorted.lists_objects.Count; i++) + { + task_list.Add(AsyncListSort(simplified); + } + await Task.WhenAll(task_list); + + return return_this; + } + public static async Task> AsyncListSort(List> double_me) + { + + } + } +} \ No newline at end of file diff --git a/multithreading/multithreading.csproj b/multithreading/multithreading.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/multithreading/multithreading.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + diff --git a/practace1/.vscode/launch.json b/practace1/.vscode/launch.json new file mode 100644 index 00000000..c7407ecf --- /dev/null +++ b/practace1/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/practace1.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/practace1/.vscode/tasks.json b/practace1/.vscode/tasks.json new file mode 100644 index 00000000..66ad1304 --- /dev/null +++ b/practace1/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/practace1.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/practace1/Program.cs b/practace1/Program.cs new file mode 100644 index 00000000..a18b867c --- /dev/null +++ b/practace1/Program.cs @@ -0,0 +1,18 @@ +using System; + +namespace practace1 +{ + class Program + { + static void Main(string[] args) + { + int number1 = 1; + int number2 = 1; + Console.WriteLine("Enter two numbers."); + number1 = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Enter next number."); + number2 = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Your added numbers are {0}", number1+number2); + } + } +} diff --git a/practace1/practace1.csproj b/practace1/practace1.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/practace1/practace1.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + diff --git a/practace2/.vscode/launch.json b/practace2/.vscode/launch.json new file mode 100644 index 00000000..b214497f --- /dev/null +++ b/practace2/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/practace2.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/practace2/.vscode/tasks.json b/practace2/.vscode/tasks.json new file mode 100644 index 00000000..a7de310e --- /dev/null +++ b/practace2/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/practace2.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/practace2/Program.cs b/practace2/Program.cs new file mode 100644 index 00000000..15ecda9b --- /dev/null +++ b/practace2/Program.cs @@ -0,0 +1,16 @@ +using System; + +namespace practace2 +{ + class Program + { + static void Main(string[] args) + { + int numberOfYards = 0; + Console.WriteLine("How many yards do you need converted?"); + numberOfYards = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("There are {1} inches in {0} yards", numberOfYards, numberOfYards*36); + + } + } +} diff --git a/practace2/practace2.csproj b/practace2/practace2.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/practace2/practace2.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + diff --git a/practace3/.vscode/launch.json b/practace3/.vscode/launch.json new file mode 100644 index 00000000..70fd5968 --- /dev/null +++ b/practace3/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/practace3.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/practace3/.vscode/tasks.json b/practace3/.vscode/tasks.json new file mode 100644 index 00000000..eafceb97 --- /dev/null +++ b/practace3/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/practace3.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/practace3/Program.cs b/practace3/Program.cs new file mode 100644 index 00000000..df47d8b9 --- /dev/null +++ b/practace3/Program.cs @@ -0,0 +1,26 @@ +using System; + +namespace practace3 +{ + class Program + { + static void Main(string[] args) + { + bool people = true; + bool f = false; + decimal num = 30.2m; + Console.WriteLine("the number {0} multiplied by itself is {1}", num, num*num); + + string firstName = "Brett"; + string lastName = "Jackson"; + int age = 33; + string job = "Network Engineer"; + string favoriteBand = "Rise Against"; + string favoriteSportsTeam = "Buffalo Bills"; + + int decToInt = Convert.ToInt32(num); + Console.WriteLine("{0} {1} {2} {3}", 100+10, 100*10, 100/10, 100-10); + + } + } +} diff --git a/practace3/practace3.csproj b/practace3/practace3.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/practace3/practace3.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + diff --git a/recursive-RockPaperScissors/.vscode/launch.json b/recursive-RockPaperScissors/.vscode/launch.json new file mode 100644 index 00000000..9dcb8f9d --- /dev/null +++ b/recursive-RockPaperScissors/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/recursive-RockPaperScissors.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/recursive-RockPaperScissors/.vscode/tasks.json b/recursive-RockPaperScissors/.vscode/tasks.json new file mode 100644 index 00000000..bc9dd6fb --- /dev/null +++ b/recursive-RockPaperScissors/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/recursive-RockPaperScissors.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/recursive-RockPaperScissors/Program.cs b/recursive-RockPaperScissors/Program.cs new file mode 100644 index 00000000..435433d5 --- /dev/null +++ b/recursive-RockPaperScissors/Program.cs @@ -0,0 +1,164 @@ +using System; + +namespace recursive_RockPaperScissors +{ + class Program + { + public static int runGame(int first, int second, string isReplay) + { + int player1 = first; + int player2 = second; + int findWinner = 0; + string player2Name = ""; + string replay = isReplay; + Console.Clear(); + Console.WriteLine("would you like to play a 2 player game {0} y/n", replay); + + if (stringToBool(Console.ReadLine())) + { + player2Name = "Player 2"; + Console.WriteLine("enter player one's selection: rock, paper, or scissors"); + string player1Guess = (simplified(Console.ReadLine())); + Console.WriteLine("enter player two's selection: rock, paper, or scissors"); + string player2Guess = (simplified(Console.ReadLine())); + findWinner = (whoWins(player1Guess, player2Guess)); + } + else + { + player2Name = "The Computer"; + Console.WriteLine("enter player ones selection: rock, paper, or scissors"); + string player1Guess = (simplified(Console.ReadLine())); + string aiGuess = (computerGuess()); + findWinner = (whoWins(player1Guess, aiGuess)); + } + + Console.WriteLine("current score is {0} to {1}.", player1, player2); + if (findWinner == 1) + { + Console.WriteLine("Player one has won this round"); + player1++; + } + else if (findWinner == 2) + { + Console.WriteLine("{0} has won this round!", player2Name); + player2++; + } + else + { + Console.WriteLine("Player1 and {0} tied this round!", player2Name); + } + + Console.Write(""); + Console.Write("play again? y/n "); + + + if (stringToBool(Console.ReadLine())) + { + replay = "this time"; + return runGame(player1, player2, replay); + } + else + { + if (player1 > player2) + { + Console.WriteLine("The final score is {0} to {1} Player 1 Wins the game!", player1, player2); + System.Threading.Thread.Sleep(2000); + return 1; + } + else if (player1 < player2) + { + Console.WriteLine("The final score is {0} to {1} {2} Wins the game!", player1, player2, player2Name); + System.Threading.Thread.Sleep(2000); + return 2; + } + else + { + Console.WriteLine("The final score is {0} to {1} the game is a tie!", player1, player2, player2Name); + System.Threading.Thread.Sleep(2000); + return 0; + } + } + + } + + public static void Main(string[] args) + { + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + Console.WriteLine("----ROCK PAPER SCISSOR SHOOT----"); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + System.Threading.Thread.Sleep(4000); + int winner = runGame(0, 0, ""); + } + + public static bool stringToBool(string userInput) + { + string simplified = userInput.Substring(0, 1).ToLower(); + if (simplified == "y") + { + return true; + } + else + { + return false; + } + } + + public static string simplified(string selection) + { + string simple = selection.ToLower().Substring(0, 1); + return simple; + } + + public static int whoWins(string first, string second) + { + int win = 0; + if (first == second) + { + win = 0; + } + else if (first == "r" && second != "p") + { + win = 1; + } + else if (first == "p" && second != "s") + { + win = 1; + } + else if (first == "s" && second != "r") + { + win = 1; + } + else + { + win = 2; + } + return win; + + } + + private static readonly Random getrandom = new Random(); + + public static string computerGuess() + { + int aiGuess = getrandom.Next(1, 4); + string guess = ""; + + switch (aiGuess) + { + case 1: + guess = "r"; + break; + case 2: + guess = "s"; + break; + case 3: + guess = "p"; + break; + default: + break; + } + + return guess; + } + } +} \ No newline at end of file diff --git a/recursive-RockPaperScissors/recursive-RockPaperScissors.csproj b/recursive-RockPaperScissors/recursive-RockPaperScissors.csproj new file mode 100644 index 00000000..8ababfd0 --- /dev/null +++ b/recursive-RockPaperScissors/recursive-RockPaperScissors.csproj @@ -0,0 +1,9 @@ + + + + Exe + netcoreapp2.2 + recursive_RockPaperScissors + + + diff --git a/sort/.vscode/launch.json b/sort/.vscode/launch.json new file mode 100644 index 00000000..7087318a --- /dev/null +++ b/sort/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/sort.dll", + "args": [], + "cwd": "${workspaceFolder}", + // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + }, + ] +} \ No newline at end of file diff --git a/sort/.vscode/tasks.json b/sort/.vscode/tasks.json new file mode 100644 index 00000000..e51bae53 --- /dev/null +++ b/sort/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/sort.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/sort/Program.cs b/sort/Program.cs new file mode 100644 index 00000000..ad07ea45 --- /dev/null +++ b/sort/Program.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; + + +namespace sort +{ + public class Program + { + public static void Main() + { + int[] arr = new int[15] { 213, 3, 4, 11, 20, 189, 2, 98, 90, 16, 76, 92, 123, 164, 247 }; + Sort(arr); + PrintResults(arr); + } + + private static void Sort(int[] arr) + { + int i, j, min; + for (i = 0; i < arr.Length; i++) + { + min = i; + for (j = 0; j < arr.Length; j++) + { + if (arr[j] > arr[min]) + { + min = j; + Swap(ref arr[i], ref arr[min]); + } + } + } + } + + private static void Swap(ref int x, ref int y) + { + int temp = x; + x = y; + y = temp; + } + private static void PrintResults(int[] arr) + { + Console.WriteLine("Sorted Values:"); + for (int i = 0; i < arr.Length; i++) + Console.WriteLine(arr[i]); + } + } +} diff --git a/sort/sort.csproj b/sort/sort.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/sort/sort.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + diff --git a/textBasedGame/.vscode/launch.json b/textBasedGame/.vscode/launch.json new file mode 100644 index 00000000..1ca2fff1 --- /dev/null +++ b/textBasedGame/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/textBasedGame.dll", + "args": [], + "cwd": "${workspaceFolder}", + // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window + "console": "integratedTerminal", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ,] +} \ No newline at end of file diff --git a/textBasedGame/.vscode/tasks.json b/textBasedGame/.vscode/tasks.json new file mode 100644 index 00000000..fd583980 --- /dev/null +++ b/textBasedGame/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/textBasedGame.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/textBasedGame/Program.cs b/textBasedGame/Program.cs new file mode 100644 index 00000000..dbd6ea25 --- /dev/null +++ b/textBasedGame/Program.cs @@ -0,0 +1,260 @@ +using System; + +namespace textBasedGame +{ + class Program + { + static void Main(string[] args) + { + bool runGame = true; + bool alive = true; + bool continueGame = true; + while(continueGame) + { + while (runGame) + { + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + Console.WriteLine("Welcome to the cavern of secrets"); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + + System.Threading.Thread.Sleep(3000); + + clearBoard(); + bool hasStick = false; + + //Take stick or not + + requestResponse(1); + string stickAnswer = Console.ReadLine(); + + if (choice(stickAnswer)) + { + Console.WriteLine("You have taken the stick!"); + hasStick = true; + } + else + { + Console.WriteLine("You did not take the stick"); + } + clearBoard(); + //go toward eye or not + requestResponse(2); + string towardObject = Console.ReadLine(); + if (choice(towardObject)) + { + //Go toward the EYE!! + clearBoard(); + Console.WriteLine("You approach the object..."); + System.Threading.Thread.Sleep(2000); + Console.WriteLine("As you draw closer, you begin to make out the object as an eye!"); + clearBoard(); + //fight spider or not + requestResponse(3); + string fightSpider = Console.ReadLine(); + + if (choice(fightSpider)) + { + // Fight Spider + bool aliveAfterFight = fightTheSpider(hasStick); + if (aliveAfterFight) + { + clearBoard(); + runGame = false; + } + else + { + clearBoard(); + alive = false; + runGame = false; + } + + } + else + { + //dont fight + clearBoard(); + Console.WriteLine("You choose not to fight the spider."); + System.Threading.Thread.Sleep(2000); + Console.WriteLine("As you turn away, it ambushes you and impales you with it's fangs!!!"); + clearBoard(); + Console.WriteLine("Press enter to continue."); + alive = false; + runGame = false; + } + + } + else + { + //AHHHH run from the Glowing thing + clearBoard(); + Console.WriteLine("You turn away from the glowing object, and attempt to leave the cave..."); + System.Threading.Thread.Sleep(2000); + Console.WriteLine("But something won't let you...."); + System.Threading.Thread.Sleep(2000); + Console.WriteLine("you slowly drift off...."); + clearBoard(); + Console.WriteLine("Press enter to continue."); + alive = false; + runGame = false; + } + } + + if(alive) + { + Console.Write("You managed to escape the cavern alive! Would you like to play again? y/n "); + } + else + { + Console.Write("You have died! Would you like to play again? y/n "); + } + + bool continuePlaying = choice(Console.ReadLine()); + Console.Clear(); + if (continuePlaying) + { + runGame = true; + alive = true; + } + else + { + Console.WriteLine("Thanks for playing"); + continueGame = false; + + } + } + } + //convert users response to a bool + public static bool choice(string userInput) + { + string simplifiedResponse = userInput.ToLower().Substring(0,1); + if (simplifiedResponse == "y") + { + bool usersChoice = true; + return usersChoice; + } + else + { + bool usersChoice = false; + return usersChoice; + } + } + public static void clearBoard() + { + System.Threading.Thread.Sleep(2000); + for (int i = 0; i <= 3; i++) + { + Console.Beep(); + } + Console.Clear(); + + } + //ask questions based on what part of the story we are in + public static void requestResponse(int questionNumber) + { + string storyQuestion = returnQuestion(questionNumber); + string[] splitQuestions = storyQuestion.Split('*'); + string firstQuestion = splitQuestions[0]; + string secondQuestion = splitQuestions[1]; + Console.WriteLine(firstQuestion); + Console.WriteLine(); + if (secondQuestion.Length > 0) + { + Console.Write("{0} y/n ", secondQuestion); + } + } + //return the question to be asked + public static string returnQuestion(int questionNumber) + { + switch (questionNumber) + { + case 1: + string question = ("You enter a dark cavern out of curiosity. It is dark and you can only make out a small stick on the floor.*Do you take it?"); + return question; + case 2: + string questionTwo = ("As you proceed further into the cave, you see a small glowing object*Do you approach the object?"); + return questionTwo; + case 3: + string questionThree = ("The eye belongs to a giant spider!*Do you try to fight it?"); + return questionThree; + default: + string gameOver = ("Game Over"); + return gameOver; + } + } + public static bool fightTheSpider(bool weapon) + { + if(weapon) + { + Console.WriteLine("You only have a stick to fight with!"); + Console.WriteLine("You quickly jab the spider in it's eye and gain an advantage"); + clearBoard(); + battleText(); + int result = Autobattle(weapon); + if (result > 0) + { + return true; + } + else + { + return false; + } + } + else + { + Console.WriteLine("You don't have anything to fight with!"); + clearBoard(); + battleText(); + int result = Autobattle(weapon); + + if (result > 0) + { + return true; + } + else + { + return false; + } + } + + } + private static readonly Random getrandom = new Random(); + public static int Autobattle(bool hasWeapon) + { + int attack = getrandom.Next(1, 8); + int defend = getrandom.Next(1, 5); + Console.WriteLine("You attacked for {0} damage", attack); + Console.WriteLine("The spider attacked for {0} damage", defend); + if (hasWeapon) + { + attack = (attack + 2); + } + int returnValue = 0; + if (attack < defend) + { + Console.WriteLine("The spider has dealt more damage than you!"); + return returnValue; + } + else if (attack < 5) + { + Console.WriteLine("You didn't do enough damage to kill the spider, but you manage to escape"); + returnValue = 1; + return returnValue; + } + else + { + Console.WriteLine("You killed the spider!"); + returnValue = 2; + return returnValue; + } + } + public static void battleText() + { + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + Console.WriteLine(" Fighting... "); + Console.WriteLine(" YOU MUST HIT ABOVE A 5 TO KILL THE SPIDER "); + Console.WriteLine("IF THE SPIDER HITS HIGHER THAN YOU, YOU WILL DIE"); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + Console.WriteLine(""); + } + } +} diff --git a/textBasedGame/bash.exe.stackdump b/textBasedGame/bash.exe.stackdump new file mode 100644 index 00000000..4bc86685 --- /dev/null +++ b/textBasedGame/bash.exe.stackdump @@ -0,0 +1,16 @@ +Stack trace: +Frame Function Args +00180328AF0 0018006021E (00180247D00, 001802340B9, 00000000058, 000FFFFB740) +00180328AF0 00180048859 (00180236765, 00100000000, 00000000000, 00000000001) +00180328AF0 00180048892 (00000000000, 00000000000, 00000000058, 00180328950) +00180328AF0 0018006C179 (0000000000A, 00000000000, 0000000000A, 00000000000) +00180328AF0 0018006C342 (00000000003, 00000000000, 00180044EEF, 000FFFFCB30) +00000000000 0018006D3A8 (0000000000D, 000FFFFC920, 001800E4CF6, 000FFFFC920) +00000000000 00180058816 (000FFFF0000, 00000000000, 00000000000, 006FFFFFFFF) +00000000000 001800590A9 (000FFFFCAF0, 00600040000, 00000000000, 000FFFFCB80) +00180325CF8 001800595BA (001800C0322, 00000000000, 00000000000, 00000000000) +000FFFFCCD0 00180059937 (000FFFFCDF0, 000FFFFCCD0, FFFFFFFFFFFFFFD1, 00000000000) +000FFFFCCD0 00180048FE1 (00000000000, 00000000000, 00000000000, 00000000000) +00000000000 00180047963 (00000000000, 00000000000, 00000000000, 00000000000) +000FFFFFFF0 00180047A14 (00000000000, 00000000000, 00000000000, 00000000000) +End of stack trace diff --git a/textBasedGame/textBasedGame.csproj b/textBasedGame/textBasedGame.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/textBasedGame/textBasedGame.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + +