From 7f38defd41cff91daf22b77c958240aef7791c81 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Jan 2019 20:40:36 -0600 Subject: [PATCH 01/74] updated with name --- HelloWorld/HelloWorld.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HelloWorld/HelloWorld.cs b/HelloWorld/HelloWorld.cs index 8168c805..99d757cf 100644 --- a/HelloWorld/HelloWorld.cs +++ b/HelloWorld/HelloWorld.cs @@ -6,7 +6,10 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + Console.WriteLine("Whats your name?"); + string yourName = Console.ReadLine(); + Console.Write("Hello {0}", yourName); + } } } From 10ad56259968259303086645a257210fb6097476 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Jan 2019 20:58:47 -0600 Subject: [PATCH 02/74] added name --- HelloWorld/.vscode/launch.json | 26 ++++++++++++++++++++++++++ HelloWorld/.vscode/tasks.json | 15 +++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 HelloWorld/.vscode/launch.json create mode 100644 HelloWorld/.vscode/tasks.json diff --git a/HelloWorld/.vscode/launch.json b/HelloWorld/.vscode/launch.json new file mode 100644 index 00000000..e49c8a02 --- /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": "internalConsole", + "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 From 3a3555f436061fb4049ab304b196c8ba3ae56d72 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Jan 2019 18:14:02 -0600 Subject: [PATCH 03/74] homework done --- HelloWorld/HelloWorld.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/HelloWorld/HelloWorld.cs b/HelloWorld/HelloWorld.cs index 99d757cf..10c84062 100644 --- a/HelloWorld/HelloWorld.cs +++ b/HelloWorld/HelloWorld.cs @@ -6,9 +6,18 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Whats your name?"); - string yourName = Console.ReadLine(); - Console.Write("Hello {0}", yourName); + 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); } } From 615cacda5241f9deb07085ac19177d6dde5acbd7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Jan 2019 19:37:36 -0600 Subject: [PATCH 04/74] practace 1 day 2 done --- HelloWorld/.vscode/launch.json | 2 +- Program.cs | 12 ++++++++++++ csharp-workbook.csproj | 9 +++++++++ practace1/.vscode/launch.json | 26 ++++++++++++++++++++++++++ practace1/.vscode/tasks.json | 15 +++++++++++++++ practace1/Program.cs | 18 ++++++++++++++++++ practace1/practace1.csproj | 8 ++++++++ 7 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 Program.cs create mode 100644 csharp-workbook.csproj create mode 100644 practace1/.vscode/launch.json create mode 100644 practace1/.vscode/tasks.json create mode 100644 practace1/Program.cs create mode 100644 practace1/practace1.csproj diff --git a/HelloWorld/.vscode/launch.json b/HelloWorld/.vscode/launch.json index e49c8a02..6fcc71fd 100644 --- a/HelloWorld/.vscode/launch.json +++ b/HelloWorld/.vscode/launch.json @@ -12,7 +12,7 @@ "program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/HelloWorld.dll", "args": [], "cwd": "${workspaceFolder}", - "console": "internalConsole", + "console": "integratedTerminal", "stopAtEntry": false, "internalConsoleOptions": "openOnSessionStart" }, 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/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/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 + + + From e6c227306b2ef5ee5d9b2f25954f51c8813f8beb Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Jan 2019 19:49:27 -0600 Subject: [PATCH 05/74] practace2 done --- practace2/.vscode/launch.json | 26 ++++++++++++++++++++++++++ practace2/.vscode/tasks.json | 15 +++++++++++++++ practace2/Program.cs | 16 ++++++++++++++++ practace2/practace2.csproj | 8 ++++++++ 4 files changed, 65 insertions(+) create mode 100644 practace2/.vscode/launch.json create mode 100644 practace2/.vscode/tasks.json create mode 100644 practace2/Program.cs create mode 100644 practace2/practace2.csproj 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 + + + From 40921ed4712bef00892717b9c99253211a61587b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Jan 2019 20:23:54 -0600 Subject: [PATCH 06/74] starting the text based adventure --- practace3/.vscode/launch.json | 26 ++++++++++++++++++++++++++ practace3/.vscode/tasks.json | 15 +++++++++++++++ practace3/Program.cs | 26 ++++++++++++++++++++++++++ practace3/practace3.csproj | 8 ++++++++ textBasedGame/.vscode/launch.json | 28 ++++++++++++++++++++++++++++ textBasedGame/.vscode/tasks.json | 15 +++++++++++++++ textBasedGame/Program.cs | 12 ++++++++++++ textBasedGame/textBasedGame.csproj | 8 ++++++++ 8 files changed, 138 insertions(+) create mode 100644 practace3/.vscode/launch.json create mode 100644 practace3/.vscode/tasks.json create mode 100644 practace3/Program.cs create mode 100644 practace3/practace3.csproj create mode 100644 textBasedGame/.vscode/launch.json create mode 100644 textBasedGame/.vscode/tasks.json create mode 100644 textBasedGame/Program.cs create mode 100644 textBasedGame/textBasedGame.csproj 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/textBasedGame/.vscode/launch.json b/textBasedGame/.vscode/launch.json new file mode 100644 index 00000000..5460677a --- /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": "internalConsole", + "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..28f0f8e8 --- /dev/null +++ b/textBasedGame/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace textBasedGame +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} 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 + + + From 2e07782b909972221be9cef0a13452c57c7f416d Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 13 Jan 2019 21:18:15 -0600 Subject: [PATCH 07/74] up to spider --- textBasedGame/.vscode/launch.json | 2 +- textBasedGame/Program.cs | 66 ++++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/textBasedGame/.vscode/launch.json b/textBasedGame/.vscode/launch.json index 5460677a..1ca2fff1 100644 --- a/textBasedGame/.vscode/launch.json +++ b/textBasedGame/.vscode/launch.json @@ -14,7 +14,7 @@ "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": "internalConsole", + "console": "integratedTerminal", "stopAtEntry": false, "internalConsoleOptions": "openOnSessionStart" }, diff --git a/textBasedGame/Program.cs b/textBasedGame/Program.cs index 28f0f8e8..bcfd7687 100644 --- a/textBasedGame/Program.cs +++ b/textBasedGame/Program.cs @@ -6,7 +6,71 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + Console.WriteLine("Welcome to the cavern of secrets"); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + + System.Threading.Thread.Sleep(3000); + + for (int i = 0; i <= 3; i++) + { + Console.Beep(); + } + + Console.Clear(); + + Console.WriteLine("You enter a dark cavern out of curiosity. It is dark and you can only make out a small stick on the floor."); + Console.WriteLine(); + Console.Write("Do you take it y/n "); + string stickAnswer = Console.ReadLine(); + + Console.Clear(); + System.Threading.Thread.Sleep(2000); + Console.Beep(); + + int stick = 0; + if (stickAnswer == "y" || stickAnswer == "Y" || stickAnswer == "yes" || stickAnswer == "Yes"){ + stick = 1; + Console.WriteLine("You have taken the stick!"); + } + else + { + stick = 0; + Console.WriteLine("You did not take the stick"); + } + + Console.Clear(); + System.Threading.Thread.Sleep(2000); + Console.Beep(); + + Console.WriteLine("As you proceed further into the cave, you see a small glowing object"); + Console.WriteLine(); + Console.Write("Do you approach the object? y/n "); + string approachAnswer = Console.ReadLine(); + + Console.Clear(); + System.Threading.Thread.Sleep(2000); + Console.Beep(); + + if (approachAnswer == "y" || approachAnswer == "Y" || approachAnswer == "yes" || approachAnswer == "Yes"){ + Console.WriteLine("You approach the object..."); + Console.Clear(); + System.Threading.Thread.Sleep(1000); + Console.Beep(); + Console.WriteLine("As you draw closer, you begin to make out the object as an eye!"); + Console.Clear(); + System.Threading.Thread.Sleep(1000); + Console.Beep(); + Console.WriteLine("The eye belongs to a giant spider!"); + Console.WriteLine(); + Console.Write("Do you try to fight it? y/n "); + } + + + + + Console.ReadLine(); } + } } From e77d929d8a0f82f5d6f41eca3b09f526dc070458 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 13 Jan 2019 21:25:54 -0600 Subject: [PATCH 08/74] up to spider --- textBasedGame/Program.cs | 8 ++++---- textBasedGame/bash.exe.stackdump | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 textBasedGame/bash.exe.stackdump diff --git a/textBasedGame/Program.cs b/textBasedGame/Program.cs index bcfd7687..1aef9599 100644 --- a/textBasedGame/Program.cs +++ b/textBasedGame/Program.cs @@ -54,13 +54,13 @@ static void Main(string[] args) if (approachAnswer == "y" || approachAnswer == "Y" || approachAnswer == "yes" || approachAnswer == "Yes"){ Console.WriteLine("You approach the object..."); - Console.Clear(); - System.Threading.Thread.Sleep(1000); + System.Threading.Thread.Sleep(2000); Console.Beep(); - Console.WriteLine("As you draw closer, you begin to make out the object as an eye!"); Console.Clear(); - System.Threading.Thread.Sleep(1000); + Console.WriteLine("As you draw closer, you begin to make out the object as an eye!"); + System.Threading.Thread.Sleep(2000); Console.Beep(); + Console.Clear(); Console.WriteLine("The eye belongs to a giant spider!"); Console.WriteLine(); Console.Write("Do you try to fight it? y/n "); 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 From 06caa326a5ffd78fff0dd53c6e110f9755e2996a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Jan 2019 19:49:56 -0600 Subject: [PATCH 09/74] committed --- textBasedGame/Program.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/textBasedGame/Program.cs b/textBasedGame/Program.cs index 1aef9599..5f28ec00 100644 --- a/textBasedGame/Program.cs +++ b/textBasedGame/Program.cs @@ -6,6 +6,7 @@ class Program { static void Main(string[] args) { + Console.WriteLine("read".substring("0")); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("Welcome to the cavern of secrets"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); @@ -39,8 +40,8 @@ static void Main(string[] args) Console.WriteLine("You did not take the stick"); } - Console.Clear(); System.Threading.Thread.Sleep(2000); + Console.Clear(); Console.Beep(); Console.WriteLine("As you proceed further into the cave, you see a small glowing object"); @@ -63,14 +64,14 @@ static void Main(string[] args) Console.Clear(); Console.WriteLine("The eye belongs to a giant spider!"); Console.WriteLine(); - Console.Write("Do you try to fight it? y/n "); + Console.Write("Do you try to fight it? y/n "); + } - + Console.ReadLine(); } - } } From 76f43bc6e2ea73e8a9fa54df128bab786c42eec2 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Jan 2019 21:01:09 -0600 Subject: [PATCH 10/74] up to spec 6 --- PigLatin/PigLatin.cs | 49 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index 702647dd..2967affd 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -7,6 +7,10 @@ class Program public static void Main() { // your code goes here + Console.WriteLine("enter a word to translate "); + string userInput = Console.ReadLine(); + string newWord = makeLowerCase(userInput); + Console.WriteLine(newWord); // leave this command at the end so your program does not close automatically Console.ReadLine(); @@ -15,7 +19,50 @@ public static void Main() public static string TranslateWord(string word) { // your code goes here - return 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 + 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 +"ay"); + + return translatedWord; + } + else + { + string notAVowel = (first + last + "ay"); + 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"); + return translatedWord; } } } From 9798f26e15c48606b6ba0bbe001e9606ddd4d3fb Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Jan 2019 18:06:42 -0600 Subject: [PATCH 11/74] up to sentence --- PigLatin/.vscode/launch.json | 26 ++++++++++++++++++++++++++ PigLatin/.vscode/tasks.json | 15 +++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 PigLatin/.vscode/launch.json create mode 100644 PigLatin/.vscode/tasks.json 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 From e405f91feb196009ee12ac291b49d852fde70d61 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Jan 2019 20:10:56 -0600 Subject: [PATCH 12/74] finished structure of question and answer portion of the game successfull through question 1 --- textBasedGame/Program.cs | 107 ++++++++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 41 deletions(-) diff --git a/textBasedGame/Program.cs b/textBasedGame/Program.cs index 5f28ec00..be217e42 100644 --- a/textBasedGame/Program.cs +++ b/textBasedGame/Program.cs @@ -6,7 +6,7 @@ class Program { static void Main(string[] args) { - Console.WriteLine("read".substring("0")); + Console.WriteLine("read".IndexOf("0")); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("Welcome to the cavern of secrets"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); @@ -17,61 +17,86 @@ static void Main(string[] args) { Console.Beep(); } - Console.Clear(); + int index = 1; + bool hasStick = false; + + //Take stick or not - Console.WriteLine("You enter a dark cavern out of curiosity. It is dark and you can only make out a small stick on the floor."); - Console.WriteLine(); - Console.Write("Do you take it y/n "); + requestResponse(1); string stickAnswer = Console.ReadLine(); - Console.Clear(); - System.Threading.Thread.Sleep(2000); - Console.Beep(); - - int stick = 0; - if (stickAnswer == "y" || stickAnswer == "Y" || stickAnswer == "yes" || stickAnswer == "Yes"){ - stick = 1; + if (choice(stickAnswer)) + { Console.WriteLine("You have taken the stick!"); + hasStick = true; } else { - stick = 0; Console.WriteLine("You did not take the stick"); } + clearBoard(); + //go toward eye or not - System.Threading.Thread.Sleep(2000); - Console.Clear(); - Console.Beep(); + //fight spider or not - Console.WriteLine("As you proceed further into the cave, you see a small glowing object"); - Console.WriteLine(); - Console.Write("Do you approach the object? y/n "); - string approachAnswer = Console.ReadLine(); - - Console.Clear(); - System.Threading.Thread.Sleep(2000); - Console.Beep(); - if (approachAnswer == "y" || approachAnswer == "Y" || approachAnswer == "yes" || approachAnswer == "Yes"){ - Console.WriteLine("You approach the object..."); - System.Threading.Thread.Sleep(2000); - Console.Beep(); - Console.Clear(); - Console.WriteLine("As you draw closer, you begin to make out the object as an eye!"); - System.Threading.Thread.Sleep(2000); + Console.ReadLine(); + } + //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(1000); + for (int i = 0; i <= 3; i++) + { Console.Beep(); - Console.Clear(); - Console.WriteLine("The eye belongs to a giant spider!"); - Console.WriteLine(); - Console.Write("Do you try to fight it? y/n "); - } - - - - - Console.ReadLine(); + 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(); + 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; + break; + case 2: + string questionTwo = (""); + return questionTwo; + break; + default: + string gameOver = ("Game Over"); + return gameOver; + break; + } } } } From de77b73ef5638a226ea4c8dc7c24d8024a8e38df Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Jan 2019 20:47:36 -0600 Subject: [PATCH 13/74] continued to fight working --- textBasedGame/Program.cs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/textBasedGame/Program.cs b/textBasedGame/Program.cs index be217e42..08417a79 100644 --- a/textBasedGame/Program.cs +++ b/textBasedGame/Program.cs @@ -6,7 +6,6 @@ class Program { static void Main(string[] args) { - Console.WriteLine("read".IndexOf("0")); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("Welcome to the cavern of secrets"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); @@ -37,7 +36,17 @@ static void Main(string[] args) } clearBoard(); //go toward eye or not - + requestResponse(2); + string towardObject = Console.ReadLine(); + if (choice(towardObject)) + { + Console.WriteLine("You have taken the stick!"); + hasStick = true; + } + else + { + Console.WriteLine("You did not take the stick"); + } //fight spider or not @@ -77,7 +86,15 @@ public static void requestResponse(int questionNumber) string secondQuestion = splitQuestions[1]; Console.WriteLine(firstQuestion); Console.WriteLine(); + if (secondQuestion.Length > 0) + { Console.Write("{0} y/n ", secondQuestion); + } + else + { + + } + } //return the question to be asked public static string returnQuestion(int questionNumber) @@ -85,13 +102,17 @@ 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"); + 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; break; case 2: - string questionTwo = (""); + string questionTwo = ("As you proceed further into the cave, you see a small glowing object*Do you approach the object?"); return questionTwo; break; + case 3: + string questionThree = ("You approach the object..."); + return questionThree; + break; default: string gameOver = ("Game Over"); return gameOver; From bb385cb40d73dd3d4c9b7f66158cd1af8a2435f6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Jan 2019 22:16:10 -0600 Subject: [PATCH 14/74] working and restarting game --- textBasedGame/Program.cs | 127 ++++++++++++++++++++++++++------------- 1 file changed, 85 insertions(+), 42 deletions(-) diff --git a/textBasedGame/Program.cs b/textBasedGame/Program.cs index 08417a79..eb3a2e3d 100644 --- a/textBasedGame/Program.cs +++ b/textBasedGame/Program.cs @@ -6,51 +6,94 @@ class Program { static void Main(string[] args) { - Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); - Console.WriteLine("Welcome to the cavern of secrets"); - Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); - - System.Threading.Thread.Sleep(3000); - - for (int i = 0; i <= 3; i++) + bool alive = true; + bool continueGame = true; + while(continueGame) { - Console.Beep(); - } - Console.Clear(); - int index = 1; - bool hasStick = false; - - //Take stick or not + while (alive) + { + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + Console.WriteLine("Welcome to the cavern of secrets"); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); - 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)) - { - Console.WriteLine("You have taken the stick!"); - hasStick = true; - } - else - { - Console.WriteLine("You did not take the stick"); - } - //fight spider or not + System.Threading.Thread.Sleep(3000); + + for (int i = 0; i <= 3; i++) + { + Console.Beep(); + } + Console.Clear(); + 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!! + Console.WriteLine("You approach the object..."); + System.Threading.Thread.Sleep(1000); + 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(); - Console.ReadLine(); + if (choice(fightSpider)) + { + + } + else + { + //dont fight + Console.WriteLine("You choose not to fight the spider."); + System.Threading.Thread.Sleep(1000); + Console.WriteLine("As you turn away, it ambushes you and impales you with it's fangs!!!"); + alive = false; + } + + } + else + { + //AHHHH run from the Glowing thing + Console.WriteLine("You turn away from the glowing object, and attempt to leave the cave..."); + System.Threading.Thread.Sleep(1000); + Console.WriteLine("But something won't let you...."); + alive = false; + } + + + + Console.ReadLine(); + } + Console.Write("Would you like to play again?"); + bool continuePlaying = choice(Console.ReadLine()); + if (continuePlaying) + { + alive = true; + } + else + { + Console.WriteLine("Thanks for playing"); + continueGame = false; + + } + } } //convert users response to a bool public static bool choice(string userInput) @@ -110,7 +153,7 @@ public static string returnQuestion(int questionNumber) return questionTwo; break; case 3: - string questionThree = ("You approach the object..."); + string questionThree = ("The eye belongs to a giant spider!*Do you try to fight it?"); return questionThree; break; default: From 28167afe6a714dd2d746ab8c9d914a1f088dedd4 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Jan 2019 22:46:50 -0600 Subject: [PATCH 15/74] built out deaths just have fight lest to build --- textBasedGame/Program.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/textBasedGame/Program.cs b/textBasedGame/Program.cs index eb3a2e3d..d132eb02 100644 --- a/textBasedGame/Program.cs +++ b/textBasedGame/Program.cs @@ -6,6 +6,7 @@ class Program { static void Main(string[] args) { + bool runGame = true; bool alive = true; bool continueGame = true; while(continueGame) @@ -53,7 +54,7 @@ static void Main(string[] args) //fight spider or not requestResponse(3); string fightSpider = Console.ReadLine(); - + if (choice(fightSpider)) { @@ -61,30 +62,51 @@ static void Main(string[] args) else { //dont fight + clearBoard(); Console.WriteLine("You choose not to fight the spider."); System.Threading.Thread.Sleep(1000); 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(1000); Console.WriteLine("But something won't let you...."); + System.Threading.Thread.Sleep(1000); + Console.WriteLine("you slowly drift off...."); + clearBoard(); + Console.WriteLine("Press enter to continue."); alive = false; + runGame = false; } Console.ReadLine(); } - Console.Write("Would you like to play again?"); + + 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()); + if (continuePlaying) { + runGame = true; alive = true; } else From ad0ccbd7cf2c20448c327b1a601d72cbbe488936 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Jan 2019 00:14:44 -0600 Subject: [PATCH 16/74] completed and tested game --- textBasedGame/Program.cs | 115 +++++++++++++++++++++++++++++++++------ 1 file changed, 98 insertions(+), 17 deletions(-) diff --git a/textBasedGame/Program.cs b/textBasedGame/Program.cs index d132eb02..aa1173e5 100644 --- a/textBasedGame/Program.cs +++ b/textBasedGame/Program.cs @@ -11,7 +11,7 @@ static void Main(string[] args) bool continueGame = true; while(continueGame) { - while (alive) + while (runGame) { Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("Welcome to the cavern of secrets"); @@ -48,7 +48,7 @@ static void Main(string[] args) { //Go toward the EYE!! Console.WriteLine("You approach the object..."); - System.Threading.Thread.Sleep(1000); + 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 @@ -57,6 +57,19 @@ static void Main(string[] args) if (choice(fightSpider)) { + // Fight Spider + bool aliveAfterFight = fightTheSpider(hasStick); + if (aliveAfterFight) + { + clearBoard(); + runGame = false; + } + else + { + clearBoard(); + alive = false; + runGame = false; + } } else @@ -64,7 +77,7 @@ static void Main(string[] args) //dont fight clearBoard(); Console.WriteLine("You choose not to fight the spider."); - System.Threading.Thread.Sleep(1000); + 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."); @@ -78,19 +91,15 @@ static void Main(string[] args) //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(1000); + System.Threading.Thread.Sleep(2000); Console.WriteLine("But something won't let you...."); - System.Threading.Thread.Sleep(1000); + System.Threading.Thread.Sleep(2000); Console.WriteLine("you slowly drift off...."); clearBoard(); Console.WriteLine("Press enter to continue."); alive = false; runGame = false; } - - - - Console.ReadLine(); } if(alive) @@ -99,11 +108,11 @@ static void Main(string[] args) } else { - Console.Write("You have died! Would you like to play again? y/n "); + Console.Write("You have died! Would you like to play again? y/n "); } bool continuePlaying = choice(Console.ReadLine()); - + Console.Clear(); if (continuePlaying) { runGame = true; @@ -134,7 +143,7 @@ public static bool choice(string userInput) } public static void clearBoard() { - System.Threading.Thread.Sleep(1000); + System.Threading.Thread.Sleep(2000); for (int i = 0; i <= 3; i++) { Console.Beep(); @@ -155,11 +164,6 @@ public static void requestResponse(int questionNumber) { Console.Write("{0} y/n ", secondQuestion); } - else - { - - } - } //return the question to be asked public static string returnQuestion(int questionNumber) @@ -184,5 +188,82 @@ public static string returnQuestion(int questionNumber) break; } } + 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(); + 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(""); + int result = Autobattle(weapon); + if (result > 0) + { + return true; + } + else + { + return false; + } + } + else + { + Console.WriteLine("You don't have anything to fight with!"); + clearBoard(); + 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(""); + 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; + } + + } } } From 7e9aae00de7891f5ed01860ca9bbfcc928c74c22 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Jan 2019 17:03:54 -0600 Subject: [PATCH 17/74] cleaned up the console clears a bit --- textBasedGame/Program.cs | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/textBasedGame/Program.cs b/textBasedGame/Program.cs index aa1173e5..c667e481 100644 --- a/textBasedGame/Program.cs +++ b/textBasedGame/Program.cs @@ -18,12 +18,7 @@ static void Main(string[] args) Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.Threading.Thread.Sleep(3000); - - for (int i = 0; i <= 3; i++) - { - Console.Beep(); - } - Console.Clear(); + clearBoard(); bool hasStick = false; //Take stick or not @@ -33,11 +28,13 @@ static void Main(string[] args) if (choice(stickAnswer)) { + clearBoard(); Console.WriteLine("You have taken the stick!"); hasStick = true; } else { + clearBoard() Console.WriteLine("You did not take the stick"); } clearBoard(); @@ -47,6 +44,7 @@ static void Main(string[] args) 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!"); @@ -121,6 +119,7 @@ static void Main(string[] args) else { Console.WriteLine("Thanks for playing"); + clearBoard(); continueGame = false; } @@ -183,7 +182,7 @@ public static string returnQuestion(int questionNumber) return questionThree; break; default: - string gameOver = ("Game Over"); + string gameOver = ("Game Over. Something went wrong"); return gameOver; break; } @@ -195,12 +194,7 @@ public static bool fightTheSpider(bool 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(); - 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(""); + battleText(); int result = Autobattle(weapon); if (result > 0) { @@ -215,12 +209,7 @@ public static bool fightTheSpider(bool weapon) { Console.WriteLine("You don't have anything to fight with!"); clearBoard(); - 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(""); + battleText(); int result = Autobattle(weapon); if (result > 0) @@ -263,7 +252,15 @@ public static int Autobattle(bool hasWeapon) 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(""); + } } } From 076bed83bd37ab24ad7eea2d49debfb924e070ec Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Jan 2019 17:23:36 -0600 Subject: [PATCH 18/74] cleaned upthe code a little ran out of time --- PigLatin/PigLatin.cs | 2 ++ textBasedGame/Program.cs | 10 ++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index 702647dd..41476638 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -19,3 +19,5 @@ public static string TranslateWord(string word) } } } + + diff --git a/textBasedGame/Program.cs b/textBasedGame/Program.cs index c667e481..dbd6ea25 100644 --- a/textBasedGame/Program.cs +++ b/textBasedGame/Program.cs @@ -18,6 +18,7 @@ static void Main(string[] args) Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.Threading.Thread.Sleep(3000); + clearBoard(); bool hasStick = false; @@ -28,13 +29,11 @@ static void Main(string[] args) if (choice(stickAnswer)) { - clearBoard(); Console.WriteLine("You have taken the stick!"); hasStick = true; } else { - clearBoard() Console.WriteLine("You did not take the stick"); } clearBoard(); @@ -119,7 +118,6 @@ static void Main(string[] args) else { Console.WriteLine("Thanks for playing"); - clearBoard(); continueGame = false; } @@ -172,19 +170,15 @@ public static string returnQuestion(int 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; - break; case 2: string questionTwo = ("As you proceed further into the cave, you see a small glowing object*Do you approach the object?"); return questionTwo; - break; case 3: string questionThree = ("The eye belongs to a giant spider!*Do you try to fight it?"); return questionThree; - break; default: - string gameOver = ("Game Over. Something went wrong"); + string gameOver = ("Game Over"); return gameOver; - break; } } public static bool fightTheSpider(bool weapon) From bfd57baf3093841c627b9652ed4c7f8c1d655202 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Jan 2019 18:20:25 -0600 Subject: [PATCH 19/74] added file path parser --- PigLatin/PigLatin.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index 2967affd..1e7d4281 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -18,7 +18,6 @@ public static void Main() public static string TranslateWord(string word) { - // your code goes here string firstLetter = word.Substring(0,1); string restWord = word.Substring(1); string translatedWord = (restWord + firstLetter + "ay"); @@ -64,5 +63,26 @@ public static string makeLowerCase(string word) string translatedWord = (restWord + firstLetter + "ay"); return translatedWord; } + + public static void filePath(string file) + { + string my_path = file; + + 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); + if (i > 0) + { + indent = indent + "|__"; + } + + output_parts.Add(String.Format("{0} {1}", indent, path_parts[i])); + } + + string tree = String.Join("\n", output_parts); + Console.Write(tree); + } } } From e82d6cb58c2a290969ec48260090dc552ed27ef0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Jan 2019 20:43:04 -0600 Subject: [PATCH 20/74] completed Rock Paper Scissors --- RockPaperScissors/RockPaperScissors.cs | 88 ++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 7 deletions(-) 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; + } } } } From f47dfa7f0b29954b56ec70ca607bb91f4f9877bc Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Jan 2019 19:24:16 -0600 Subject: [PATCH 21/74] added recursive ROCK PAPER SCISSOR from fiddle --- RockPaperScissors/.vscode/launch.json | 28 +++ RockPaperScissors/.vscode/tasks.json | 15 ++ .../.vscode/launch.json | 26 +++ .../.vscode/tasks.json | 15 ++ recursive-RockPaperScissors/Program.cs | 164 ++++++++++++++++++ .../recursive-RockPaperScissors.csproj | 9 + 6 files changed, 257 insertions(+) create mode 100644 RockPaperScissors/.vscode/launch.json create mode 100644 RockPaperScissors/.vscode/tasks.json create mode 100644 recursive-RockPaperScissors/.vscode/launch.json create mode 100644 recursive-RockPaperScissors/.vscode/tasks.json create mode 100644 recursive-RockPaperScissors/Program.cs create mode 100644 recursive-RockPaperScissors/recursive-RockPaperScissors.csproj 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/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 + + + From 89fa722541274784f4d509d52037079677bcb4b0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Jan 2019 20:36:37 -0600 Subject: [PATCH 22/74] finishing sentence for piglatin --- PigLatin/PigLatin.cs | 79 ++++++++++++++++++++++--------------- PigLatin/bash.exe.stackdump | 16 ++++++++ 2 files changed, 63 insertions(+), 32 deletions(-) create mode 100644 PigLatin/bash.exe.stackdump diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index 1e7d4281..a928a8c5 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -9,16 +9,39 @@ public static void Main() // your code goes here Console.WriteLine("enter a word to translate "); string userInput = Console.ReadLine(); - string newWord = makeLowerCase(userInput); + 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(); + moreWords(userInputSentence); + Console.Write("oops let me fix that punctuation"); + for (int i = 0; i < 5; i++) + { + System.Threading.Thread.Sleep(2000); + Console.Write("."); + } // 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 firstLetter = word.Substring(0, 1); string restWord = word.Substring(1); string translatedWord = (restWord + firstLetter + "ay"); return translatedWord; @@ -27,7 +50,7 @@ public static string TranslateWord(string word) public static string TranslateWordVowel(string word) { // your code goes here - int firstVowelIndex = word.IndexOfAny(new char[] {'a', 'e', 'i', 'o', 'u', 'y'}); + 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"); @@ -38,51 +61,43 @@ public static string TranslateWordVowel(string word) 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); + 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 +"ay"); + string translatedWord = (last + first + "yay"); - return translatedWord; + return translatedWord; } else { - string notAVowel = (first + last + "ay"); + 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 firstLetter = convertLower.Substring(0, 1); string restWord = convertLower.Substring(1); - string translatedWord = (restWord + firstLetter + "ay"); - return translatedWord; + string translatedWord = (restWord + firstLetter + "ay (try a word that has differant cased letters!)"); + return translatedWord; } - - public static void filePath(string file) + public static string moreWords(string words) { - string my_path = file; - - 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); - if (i > 0) - { - indent = indent + "|__"; - } - - output_parts.Add(String.Format("{0} {1}", indent, path_parts[i])); - } - - string tree = String.Join("\n", output_parts); - Console.Write(tree); + 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 upperCaseString = String.Join(" ", translatedWords); + return upperCaseString; } } } 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 From d937d14c1734463a8cf34eadae2454a1c6816c13 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Jan 2019 21:11:09 -0600 Subject: [PATCH 23/74] finished up --- PigLatin/PigLatin.cs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index a928a8c5..468a21ae 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -28,13 +28,16 @@ public static void Main() Console.WriteLine("Let's try a whole sentence!"); string userInputSentence = Console.ReadLine(); - moreWords(userInputSentence); + 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(2000); Console.Write("."); } + string fixTranslation = fixPunctuation(translatedSentence); + Console.WriteLine(fixTranslation); // leave this command at the end so your program does not close automatically Console.ReadLine(); } @@ -96,8 +99,28 @@ public static string moreWords(string words) string restWord = allWords[i].Substring(1); translatedWords[i] = (restWord + firstLetter + "ay"); } - string upperCaseString = String.Join(" ", translatedWords); - return upperCaseString; + 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); + } + } + string translatedString = String.Join(" ", correctedWords); + return translatedString; } } } From 1f64a7039a434d04df1195d2926c210dbb3c0455 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Jan 2019 21:16:22 -0600 Subject: [PATCH 24/74] completed --- PigLatin/PigLatin.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index 468a21ae..c27838d7 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -33,9 +33,10 @@ public static void Main() Console.Write("oops let me fix that punctuation"); for (int i = 0; i < 5; i++) { - System.Threading.Thread.Sleep(2000); + 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 @@ -118,6 +119,10 @@ public static string fixPunctuation(string words) string secondPart = secondPartlast + secondPartFirst; correctedWords[i] = (firstPart + secondPart); } + else + { + correctedWords[i] = allWords[i]; + } } string translatedString = String.Join(" ", correctedWords); return translatedString; From 734e03860f59261e16fee7f15a643d145d1533f2 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Jan 2019 21:56:16 -0600 Subject: [PATCH 25/74] file path bonus completed --- fileTreeBonus/.vscode/launch.json | 26 ++++++++++++++++++++++++++ fileTreeBonus/.vscode/tasks.json | 15 +++++++++++++++ fileTreeBonus/Program.cs | 30 ++++++++++++++++++++++++++++++ fileTreeBonus/fileTreeBonus.csproj | 8 ++++++++ 4 files changed, 79 insertions(+) create mode 100644 fileTreeBonus/.vscode/launch.json create mode 100644 fileTreeBonus/.vscode/tasks.json create mode 100644 fileTreeBonus/Program.cs create mode 100644 fileTreeBonus/fileTreeBonus.csproj 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 + + + From c0b7de3b830e53c51c6ab3d9e5b9e0d7cef8dcb4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Jan 2019 16:32:17 -0600 Subject: [PATCH 26/74] finished fizzbuzz --- FizzBuzz/FizzBuzz.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/FizzBuzz/FizzBuzz.cs b/FizzBuzz/FizzBuzz.cs index 9246f703..1ee45184 100644 --- a/FizzBuzz/FizzBuzz.cs +++ b/FizzBuzz/FizzBuzz.cs @@ -6,7 +6,25 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + for (int i = 1; i < 100; i++) + { + if (i % 3 == 0 && i % 5 == 0) + { + Console.WriteLine("FIZZBUZZ"); + } + else if (i % 3 == 0) + { + Console.WriteLine("FIZZ"); + } + else if (i % 5 == 0) + { + Console.WriteLine("BUZZ"); + } + else + { + Console.WriteLine(i); + } + } } } } From e366f6bff37b516de141add79689c43fc5d1b8c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 25 Jan 2019 07:52:07 -0600 Subject: [PATCH 27/74] finished fizzbuzz --- FizzBuzz/FizzBuzz.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/FizzBuzz/FizzBuzz.cs b/FizzBuzz/FizzBuzz.cs index 1ee45184..075857d4 100644 --- a/FizzBuzz/FizzBuzz.cs +++ b/FizzBuzz/FizzBuzz.cs @@ -1,4 +1,6 @@ using System; +using System.Linq; +using System.Collections.Generic; namespace FizzBuzz { @@ -8,23 +10,22 @@ static void Main(string[] args) { for (int i = 1; i < 100; i++) { - if (i % 3 == 0 && i % 5 == 0) + if (i % 3 == 0) { - Console.WriteLine("FIZZBUZZ"); + Console.Write("FIZZ"); } - else if (i % 3 == 0) + if (i % 5 == 0) { - Console.WriteLine("FIZZ"); + Console.Write("BUZZ"); } - else if (i % 5 == 0) + if (i % 3 != 0 && i % 5 != 0) { - Console.WriteLine("BUZZ"); - } - else - { - Console.WriteLine(i); + Console.Write(i); } + Console.Write("\n\r"); } + // 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); } } } From fd34e25c0e5c29a844109b748b0124bea096b286 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 26 Jan 2019 13:43:48 -0600 Subject: [PATCH 28/74] finished fizzbuzz --- FizzBuzz/FizzBuzz.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FizzBuzz/FizzBuzz.cs b/FizzBuzz/FizzBuzz.cs index 075857d4..27b1e5c1 100644 --- a/FizzBuzz/FizzBuzz.cs +++ b/FizzBuzz/FizzBuzz.cs @@ -22,7 +22,7 @@ static void Main(string[] args) { Console.Write(i); } - Console.Write("\n\r"); + 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); From 424e0a75876d227df44be9b5eb646a4db688bc6e Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 26 Jan 2019 13:49:38 -0600 Subject: [PATCH 29/74] finished shell --- sort/.vscode/launch.json | 28 ++++++++++++++++++++++++++++ sort/.vscode/tasks.json | 15 +++++++++++++++ sort/Program.cs | 20 ++++++++++++++++++++ sort/sort.csproj | 8 ++++++++ 4 files changed, 71 insertions(+) create mode 100644 sort/.vscode/launch.json create mode 100644 sort/.vscode/tasks.json create mode 100644 sort/Program.cs create mode 100644 sort/sort.csproj diff --git a/sort/.vscode/launch.json b/sort/.vscode/launch.json new file mode 100644 index 00000000..d047266f --- /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": "internalConsole", + "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..50e69e9c --- /dev/null +++ b/sort/Program.cs @@ -0,0 +1,20 @@ +using System; + +namespace sort +{ + class Program + { + static void Main(string[] args) + { + int[] arrToSort = new int[20] { 3, 64, 5, 6, 677, 8, 889, 44, 33, 2, 2221, 44, 55, 6, 77, 88, 89, 45, 32, 6 }; + int[] sortedArray = SortArray(arrToSort); + + } + + public static int[] SortArray(int[] array) + { + //sort the array here + return array; + } + } +} 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 + + + From af8c40509dc3a6ee6d73fb250a6415777a644e37 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 26 Jan 2019 14:03:56 -0600 Subject: [PATCH 30/74] looping through the array and finding the next smallest, have an issue with swapping the 2 values --- sort/Program.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sort/Program.cs b/sort/Program.cs index 50e69e9c..1135269b 100644 --- a/sort/Program.cs +++ b/sort/Program.cs @@ -14,6 +14,20 @@ static void Main(string[] args) public static int[] SortArray(int[] array) { //sort the array here + int min; + for (int i = 0; i < array.Length; i++) + { + min = i; + for (int j = 0; j < array.Length; j++) + { + if (array[j] > array[min]) + { + min = j; + //need to swap these 2 without losing one + // array[i] / array[min]; + } + } + } return array; } } From e7f5616f18933d3ee170af8e679f854ded3fcdae Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 26 Jan 2019 14:13:13 -0600 Subject: [PATCH 31/74] Still cant get it to work but leaving coffee shop --- sort/Program.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sort/Program.cs b/sort/Program.cs index 1135269b..b429cea9 100644 --- a/sort/Program.cs +++ b/sort/Program.cs @@ -14,6 +14,7 @@ static void Main(string[] args) public static int[] SortArray(int[] array) { //sort the array here + int[] sortedArray = array; int min; for (int i = 0; i < array.Length; i++) { @@ -23,8 +24,8 @@ public static int[] SortArray(int[] array) if (array[j] > array[min]) { min = j; - //need to swap these 2 without losing one - // array[i] / array[min]; + int placeHolder = array[i] + sortedArray[i] = array[min]; } } } From 0a09b3927958474ca7fc8e8931121968130c0844 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 26 Jan 2019 14:19:22 -0600 Subject: [PATCH 32/74] tryed one more thing still not working it just returns 1 value over and over --- sort/.vscode/launch.json | 16 ++++++++-------- sort/Program.cs | 8 ++++++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/sort/.vscode/launch.json b/sort/.vscode/launch.json index d047266f..7087318a 100644 --- a/sort/.vscode/launch.json +++ b/sort/.vscode/launch.json @@ -1,9 +1,9 @@ { - // 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": [ + // 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", @@ -14,7 +14,7 @@ "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": "internalConsole", + "console": "integratedTerminal", "stopAtEntry": false, "internalConsoleOptions": "openOnSessionStart" }, @@ -23,6 +23,6 @@ "type": "coreclr", "request": "attach", "processId": "${command:pickProcess}" - } - ,] + }, + ] } \ No newline at end of file diff --git a/sort/Program.cs b/sort/Program.cs index b429cea9..099ac8f0 100644 --- a/sort/Program.cs +++ b/sort/Program.cs @@ -8,6 +8,10 @@ static void Main(string[] args) { int[] arrToSort = new int[20] { 3, 64, 5, 6, 677, 8, 889, 44, 33, 2, 2221, 44, 55, 6, 77, 88, 89, 45, 32, 6 }; int[] sortedArray = SortArray(arrToSort); + for (int i = 0; i < sortedArray.Length; i++) + { + Console.Write("{0}, ", sortedArray[i]); + } } @@ -24,12 +28,12 @@ public static int[] SortArray(int[] array) if (array[j] > array[min]) { min = j; - int placeHolder = array[i] + int placeHolder = array[i]; sortedArray[i] = array[min]; } } } - return array; + return sortedArray; } } } From 4b0e0a05f1328caa0b2da60fa9ba3066513a4d20 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 26 Jan 2019 16:12:43 -0600 Subject: [PATCH 33/74] changing stratagy need to see if c# can run functions simultaneously --- sort/Program.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/sort/Program.cs b/sort/Program.cs index 099ac8f0..d2104ced 100644 --- a/sort/Program.cs +++ b/sort/Program.cs @@ -6,19 +6,18 @@ class Program { static void Main(string[] args) { - int[] arrToSort = new int[20] { 3, 64, 5, 6, 677, 8, 889, 44, 33, 2, 2221, 44, 55, 6, 77, 88, 89, 45, 32, 6 }; - int[] sortedArray = SortArray(arrToSort); - for (int i = 0; i < sortedArray.Length; i++) + int[] arrayToSort = new int[20] { 3, 64, 5, 6, 677, 8, 889, 44, 33, 2, 2221, 44, 55, 6, 77, 88, 89, 45, 32, 6 }; + SortArray(arrayToSort); + for (int i = 0; i < arrayToSort.Length; i++) { - Console.Write("{0}, ", sortedArray[i]); + Console.Write("{0}, ", arrayToSort[i]); } } - public static int[] SortArray(int[] array) + public static void Sortparts(int[] array) { //sort the array here - int[] sortedArray = array; int min; for (int i = 0; i < array.Length; i++) { @@ -29,11 +28,10 @@ public static int[] SortArray(int[] array) { min = j; int placeHolder = array[i]; - sortedArray[i] = array[min]; + array[i] = array[min]; } } } - return sortedArray; } } } From d05a9d3b4640b470a5a08b1db9923053be16b62c Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 26 Jan 2019 16:16:01 -0600 Subject: [PATCH 34/74] testing 'workers' --- sort/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/sort/Program.cs b/sort/Program.cs index d2104ced..573f93d3 100644 --- a/sort/Program.cs +++ b/sort/Program.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel; namespace sort { From dea8ccf4ec1b9eaed8727e862ac57ee923d16367 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 26 Jan 2019 16:27:30 -0600 Subject: [PATCH 35/74] successfuly went down rabbit hole, need to read more on objects, constructors and events --- sort/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/sort/Program.cs b/sort/Program.cs index 573f93d3..52abfc6a 100644 --- a/sort/Program.cs +++ b/sort/Program.cs @@ -5,6 +5,7 @@ namespace sort { class Program { + //restarting static void Main(string[] args) { int[] arrayToSort = new int[20] { 3, 64, 5, 6, 677, 8, 889, 44, 33, 2, 2221, 44, 55, 6, 77, 88, 89, 45, 32, 6 }; From 10c3fed1e5013546d0e18c4cdabef689a2a20fb8 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 26 Jan 2019 21:00:34 -0600 Subject: [PATCH 36/74] shell of multithread done may need 1 more thread --- multithreading/.vscode/launch.json | 26 +++++++++++++++++++ multithreading/.vscode/tasks.json | 15 +++++++++++ multithreading/Program.cs | 37 ++++++++++++++++++++++++++++ multithreading/multithreading.csproj | 8 ++++++ 4 files changed, 86 insertions(+) create mode 100644 multithreading/.vscode/launch.json create mode 100644 multithreading/.vscode/tasks.json create mode 100644 multithreading/Program.cs create mode 100644 multithreading/multithreading.csproj 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..fcfe06d0 --- /dev/null +++ b/multithreading/Program.cs @@ -0,0 +1,37 @@ +using System; +using System.Threading; + + +public class SortWithMultiThread +{ + public static void PartialSort() + { + for (int i = 0; i < 10; i++) + { + + // Yield the rest of the time slice. + Thread.Sleep(0); + } + } + + public static void Main() + { + + // The constructor for the Thread. + Thread sortingThread = new Thread(new ThreadStart(PartialSort)); + + //start thread + sortingThread.Start(); + + for (int i = 0; i < 4; i++) + { + + Thread.Sleep(0); + } + + //join threads + sortingThread.Join(); + //Join has returned + Console.ReadLine(); + } +} \ 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 + + + From 86e2b73533615ceeba9c1e9196e1c7e7adbe8a86 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 27 Jan 2019 00:39:16 -0600 Subject: [PATCH 37/74] finished splitting the array into a larger # array and smaller (partial sort) about to go async on both halves --- multithreading/Program.cs | 41 ++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index fcfe06d0..98a42807 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -1,10 +1,13 @@ using System; using System.Threading; +using System.Linq; + public class SortWithMultiThread { - public static void PartialSort() + + public static void PartialSort(int[] arr) { for (int i = 0; i < 10; i++) { @@ -16,16 +19,44 @@ public static void PartialSort() public static void Main() { + //split-half sort array into 2 sub arrays 1 containg the numbers that are > than average and one <= average + int[] arrayToSort = new int[20] { 13, 57, 34, 151, 70, 68, 222, 149, 64, 165, 1, 5, 4, 11, 20, 8, 2, 98, 90, 16 }; - // The constructor for the Thread. - Thread sortingThread = new Thread(new ThreadStart(PartialSort)); + int[] smallerThanAverage = new int[20]; + int average; + int indexOfHalf = 0; + int sum = arrayToSort.Sum(); + average = sum / arrayToSort.Length; + for (int i = 0; i < arrayToSort.Length; i++) + { + if (arrayToSort[i] <= sum) + { + smallerThanAverage[indexOfHalf] = arrayToSort[i]; + indexOfHalf++; + } + else + { + smallerThanAverage[20 - indexOfHalf] = arrayToSort[i]; + } + } + int[] asyncSortThis = new int[10]; + int j = 0; + for (int i = 11; i < smallerThanAverage.Length; i++) + { + asyncSortThis[i] = smallerThanAverage[j]; + j++; + } + + + // The constructor for the Thread. + Thread sortingThread = new Thread(new ThreadStart(() => PartialSort(asyncSortThis))); //start thread sortingThread.Start(); - for (int i = 0; i < 4; i++) + for (int i = 0; i < 10; i++) { - + // Yield the rest of the time slice. Thread.Sleep(0); } From c898087edc262e83e0c78468991af86db584eb3d Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 27 Jan 2019 00:54:33 -0600 Subject: [PATCH 38/74] done for now --- multithreading/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index 98a42807..cc624dc3 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -30,7 +30,7 @@ public static void Main() for (int i = 0; i < arrayToSort.Length; i++) { - if (arrayToSort[i] <= sum) + if (arrayToSort[i] <= average) { smallerThanAverage[indexOfHalf] = arrayToSort[i]; indexOfHalf++; @@ -40,6 +40,7 @@ public static void Main() smallerThanAverage[20 - indexOfHalf] = arrayToSort[i]; } } + int[] asyncSortThis = new int[10]; int j = 0; for (int i = 11; i < smallerThanAverage.Length; i++) From d92eb53c7ca19377a41373f1b5b1e4ffda3164cc Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 27 Jan 2019 12:15:10 -0600 Subject: [PATCH 39/74] array is now split into 2 arrays 1 containing higher values and one lower --- multithreading/Program.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index cc624dc3..b01cea15 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -24,7 +24,8 @@ public static void Main() int[] smallerThanAverage = new int[20]; int average; - int indexOfHalf = 0; + int indexOfLowerHalf = 0; + int indexOfHigherHalf = 19; int sum = arrayToSort.Sum(); average = sum / arrayToSort.Length; @@ -32,12 +33,13 @@ public static void Main() { if (arrayToSort[i] <= average) { - smallerThanAverage[indexOfHalf] = arrayToSort[i]; - indexOfHalf++; + smallerThanAverage[indexOfLowerHalf] = arrayToSort[i]; + indexOfLowerHalf++; } else { - smallerThanAverage[20 - indexOfHalf] = arrayToSort[i]; + smallerThanAverage[indexOfHigherHalf] = arrayToSort[i]; + indexOfHigherHalf--; } } @@ -45,7 +47,7 @@ public static void Main() int j = 0; for (int i = 11; i < smallerThanAverage.Length; i++) { - asyncSortThis[i] = smallerThanAverage[j]; + asyncSortThis[j] = smallerThanAverage[i]; j++; } From cb3a7a9aa4999ddb6c5cc4f7962c17a4a6393010 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 27 Jan 2019 13:42:46 -0600 Subject: [PATCH 40/74] fixed a bug where it was inserting a 0 into the async array --- multithreading/Program.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index b01cea15..a55eaa0d 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -22,10 +22,10 @@ public static void Main() //split-half sort array into 2 sub arrays 1 containg the numbers that are > than average and one <= average int[] arrayToSort = new int[20] { 13, 57, 34, 151, 70, 68, 222, 149, 64, 165, 1, 5, 4, 11, 20, 8, 2, 98, 90, 16 }; - int[] smallerThanAverage = new int[20]; + int[] smallerThanAverage = new int[arrayToSort.Length]; int average; int indexOfLowerHalf = 0; - int indexOfHigherHalf = 19; + int indexOfHigherHalf = arrayToSort.Length - 1; int sum = arrayToSort.Sum(); average = sum / arrayToSort.Length; @@ -42,10 +42,9 @@ public static void Main() indexOfHigherHalf--; } } - - int[] asyncSortThis = new int[10]; + int[] asyncSortThis = new int[(smallerThanAverage.Length / 2) - 1]; int j = 0; - for (int i = 11; i < smallerThanAverage.Length; i++) + for (int i = (smallerThanAverage.Length / 2) + 1; j < asyncSortThis.Length; i++) { asyncSortThis[j] = smallerThanAverage[i]; j++; From 26d5d1be1e4f43f710ac84eb3710dbcdab206d33 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 27 Jan 2019 15:41:01 -0600 Subject: [PATCH 41/74] made an unfortunate assumption about how the sort will happenso things are divided into chunks of 9 and 11... 10 and 10 fixes it but it coded all the way through look at the end before coding in the future --- multithreading/Program.cs | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index a55eaa0d..9758cae6 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -7,14 +7,38 @@ public class SortWithMultiThread { - public static void PartialSort(int[] arr) + public static int[] PartialSort(int[] arr) { - for (int i = 0; i < 10; i++) - { + int[] arrayToSort = arr; - // Yield the rest of the time slice. - Thread.Sleep(0); + int[] smallerThanAverage = new int[arrayToSort.Length]; + int average; + int indexOfLowerHalf = 0; + int indexOfHigherHalf = arrayToSort.Length - 1; + int sum = arrayToSort.Sum(); + average = sum / arrayToSort.Length; + + for (int i = 0; i < arrayToSort.Length; i++) + { + if (arrayToSort[i] <= average) + { + smallerThanAverage[indexOfLowerHalf] = arrayToSort[i]; + indexOfLowerHalf++; + } + else + { + smallerThanAverage[indexOfHigherHalf] = arrayToSort[i]; + indexOfHigherHalf--; + } } + int[] asyncSortThis = new int[(smallerThanAverage.Length / 2) - 1]; + int j = 0; + for (int i = (smallerThanAverage.Length / 2) + 1; j < asyncSortThis.Length; i++) + { + asyncSortThis[j] = smallerThanAverage[i]; + j++; + } + return arr; } public static void Main() @@ -51,13 +75,14 @@ public static void Main() } - // The constructor for the Thread. + // The constructor for a Thread. Thread sortingThread = new Thread(new ThreadStart(() => PartialSort(asyncSortThis))); //start thread sortingThread.Start(); - for (int i = 0; i < 10; i++) + for (int i = 0; i <= (smallerThanAverage.Length / 2) + 1; i++) { + // Yield the rest of the time slice. Thread.Sleep(0); } From 026bac857496f5e9623a2d7f5a3b44f526f6799a Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 27 Jan 2019 19:14:29 -0600 Subject: [PATCH 42/74] there is a more modern way of doing this --- multithreading/Program.cs | 42 ++++++++++----------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index 9758cae6..4c26f0bb 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -6,7 +6,7 @@ public class SortWithMultiThread { - + //used for sorting an arr of unique values public static int[] PartialSort(int[] arr) { int[] arrayToSort = arr; @@ -38,39 +38,21 @@ public static int[] PartialSort(int[] arr) asyncSortThis[j] = smallerThanAverage[i]; j++; } - return arr; + int[] smallerArr = asyncSortThis; + return smallerArr; } public static void Main() { //split-half sort array into 2 sub arrays 1 containg the numbers that are > than average and one <= average - int[] arrayToSort = new int[20] { 13, 57, 34, 151, 70, 68, 222, 149, 64, 165, 1, 5, 4, 11, 20, 8, 2, 98, 90, 16 }; + int[] inputArray = new int[20] { 13, 57, 34, 151, 70, 68, 222, 149, 64, 165, 1, 5, 4, 11, 20, 8, 2, 98, 90, 16 }; + int[] splitHalf = PartialSort(inputArray); - int[] smallerThanAverage = new int[arrayToSort.Length]; - int average; - int indexOfLowerHalf = 0; - int indexOfHigherHalf = arrayToSort.Length - 1; - int sum = arrayToSort.Sum(); - average = sum / arrayToSort.Length; - - for (int i = 0; i < arrayToSort.Length; i++) - { - if (arrayToSort[i] <= average) - { - smallerThanAverage[indexOfLowerHalf] = arrayToSort[i]; - indexOfLowerHalf++; - } - else - { - smallerThanAverage[indexOfHigherHalf] = arrayToSort[i]; - indexOfHigherHalf--; - } - } - int[] asyncSortThis = new int[(smallerThanAverage.Length / 2) - 1]; + int[] asyncSortThis = new int[(splitHalf.Length / 2) - 1]; int j = 0; - for (int i = (smallerThanAverage.Length / 2) + 1; j < asyncSortThis.Length; i++) + for (int i = (splitHalf.Length / 2) + 1; j < asyncSortThis.Length; i++) { - asyncSortThis[j] = smallerThanAverage[i]; + asyncSortThis[j] = splitHalf[i]; j++; } @@ -80,12 +62,10 @@ public static void Main() //start thread sortingThread.Start(); - for (int i = 0; i <= (smallerThanAverage.Length / 2) + 1; i++) - { + PartialSort(int[] arr); + // Yield the rest of the time slice. + Thread.Sleep(0); - // Yield the rest of the time slice. - Thread.Sleep(0); - } //join threads sortingThread.Join(); From 6aaf82c2b9371f0110dab1b5685cb3b113b8cd08 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 27 Jan 2019 22:55:57 -0600 Subject: [PATCH 43/74] closures may solve this issue i need to fix tie in ticTacToeand other flaws, tic tac toe due tomorrow this wed --- multithreading/Program.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index 4c26f0bb..84aa8669 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -1,5 +1,5 @@ using System; -using System.Threading; +using System.Threading.Tasks; using System.Linq; @@ -8,6 +8,11 @@ public class SortWithMultiThread { //used for sorting an arr of unique values public static int[] PartialSort(int[] arr) + { + + } + + static async Task SplitAgain(int[] arr) { int[] arrayToSort = arr; @@ -33,13 +38,13 @@ public static int[] PartialSort(int[] arr) } int[] asyncSortThis = new int[(smallerThanAverage.Length / 2) - 1]; int j = 0; - for (int i = (smallerThanAverage.Length / 2) + 1; j < asyncSortThis.Length; i++) + for (int i = smallerThanAverage.Length / 2; j < asyncSortThis.Length; i++) { asyncSortThis[j] = smallerThanAverage[i]; j++; } int[] smallerArr = asyncSortThis; - return smallerArr; + } public static void Main() @@ -56,20 +61,15 @@ public static void Main() j++; } - // The constructor for a Thread. - Thread sortingThread = new Thread(new ThreadStart(() => PartialSort(asyncSortThis))); + //Thread sortingThread = new Thread(new ThreadStart(() => PartialSort(asyncSortThis))); //start thread - sortingThread.Start(); - - PartialSort(int[] arr); - // Yield the rest of the time slice. - Thread.Sleep(0); - + //sortingThread.Start(); - //join threads - sortingThread.Join(); - //Join has returned + int[] firstHalf = PartialSort(splitHalf); + //Thread.Sleep(0); + //sortingThread.Join(); + //int[] secondHalf = smallerArr;//?? Console.ReadLine(); } } \ No newline at end of file From a024e4553f07e4cff954c08b2d03f59e5bca3f62 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 Jan 2019 17:40:53 -0600 Subject: [PATCH 44/74] spoke to my sr dev today about this and was advised to not do it this way ha so now just have to learn to use functions as a type --- guessingGame/.vscode/launch.json | 26 ++++++++++++++++++++++ guessingGame/.vscode/tasks.json | 15 +++++++++++++ guessingGame/Program.cs | 38 ++++++++++++++++++++++++++++++++ guessingGame/guessingGame.csproj | 8 +++++++ multithreading/Program.cs | 27 ++++++++++++++--------- 5 files changed, 103 insertions(+), 11 deletions(-) create mode 100644 guessingGame/.vscode/launch.json create mode 100644 guessingGame/.vscode/tasks.json create mode 100644 guessingGame/Program.cs create mode 100644 guessingGame/guessingGame.csproj 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/Program.cs b/multithreading/Program.cs index 84aa8669..2de3cf41 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using System.Collections.Generic; using System.Linq; @@ -49,7 +50,6 @@ static async Task SplitAgain(int[] arr) public static void Main() { - //split-half sort array into 2 sub arrays 1 containg the numbers that are > than average and one <= average int[] inputArray = new int[20] { 13, 57, 34, 151, 70, 68, 222, 149, 64, 165, 1, 5, 4, 11, 20, 8, 2, 98, 90, 16 }; int[] splitHalf = PartialSort(inputArray); @@ -60,16 +60,21 @@ public static void Main() asyncSortThis[j] = splitHalf[i]; j++; } + } - // The constructor for a Thread. - //Thread sortingThread = new Thread(new ThreadStart(() => PartialSort(asyncSortThis))); - //start thread - //sortingThread.Start(); - - int[] firstHalf = PartialSort(splitHalf); - //Thread.Sleep(0); - //sortingThread.Join(); - //int[] secondHalf = smallerArr;//?? - Console.ReadLine(); + public static async Task> split(int[] nums) + { + var taskList = new List>(); + foreach (var num in nums) + { + taskList.Add(SplitAgain(num)); + } + await Task.WhenAll(taskList); + List resp = new List(); + foreach (var tsk in taskList) + { + resp.Add(tsk.Result); + } + return resp; } } \ No newline at end of file From f259583b5927a8d7983d92d1d02a06f9fb8b1270 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 Jan 2019 17:46:25 -0600 Subject: [PATCH 45/74] starting from scratch..... --- multithreading/Program.cs | 71 ++------------------------------------- 1 file changed, 2 insertions(+), 69 deletions(-) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index 2de3cf41..177018d5 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -3,78 +3,11 @@ using System.Collections.Generic; using System.Linq; - - -public class SortWithMultiThread +public class Program { - //used for sorting an arr of unique values - public static int[] PartialSort(int[] arr) - { - - } - - static async Task SplitAgain(int[] arr) - { - int[] arrayToSort = arr; - - int[] smallerThanAverage = new int[arrayToSort.Length]; - int average; - int indexOfLowerHalf = 0; - int indexOfHigherHalf = arrayToSort.Length - 1; - int sum = arrayToSort.Sum(); - average = sum / arrayToSort.Length; - - for (int i = 0; i < arrayToSort.Length; i++) - { - if (arrayToSort[i] <= average) - { - smallerThanAverage[indexOfLowerHalf] = arrayToSort[i]; - indexOfLowerHalf++; - } - else - { - smallerThanAverage[indexOfHigherHalf] = arrayToSort[i]; - indexOfHigherHalf--; - } - } - int[] asyncSortThis = new int[(smallerThanAverage.Length / 2) - 1]; - int j = 0; - for (int i = smallerThanAverage.Length / 2; j < asyncSortThis.Length; i++) - { - asyncSortThis[j] = smallerThanAverage[i]; - j++; - } - int[] smallerArr = asyncSortThis; - - } - public static void Main() { - int[] inputArray = new int[20] { 13, 57, 34, 151, 70, 68, 222, 149, 64, 165, 1, 5, 4, 11, 20, 8, 2, 98, 90, 16 }; - int[] splitHalf = PartialSort(inputArray); - int[] asyncSortThis = new int[(splitHalf.Length / 2) - 1]; - int j = 0; - for (int i = (splitHalf.Length / 2) + 1; j < asyncSortThis.Length; i++) - { - asyncSortThis[j] = splitHalf[i]; - j++; - } } +} - public static async Task> split(int[] nums) - { - var taskList = new List>(); - foreach (var num in nums) - { - taskList.Add(SplitAgain(num)); - } - await Task.WhenAll(taskList); - List resp = new List(); - foreach (var tsk in taskList) - { - resp.Add(tsk.Result); - } - return resp; - } -} \ No newline at end of file From dfa5d5d724251d188db3c38320a7d705e11f6171 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 Jan 2019 18:33:10 -0600 Subject: [PATCH 46/74] have the basic gameplan --- multithreading/Program.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index 177018d5..97147f9d 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -7,7 +7,20 @@ public class Program { public static void Main() { + var results = new List { 4, 5, 10, 12, 14, 20, 1, 205, 26, 31, 120, 2, 3, 72, 40, 100, 140 }; + double average = results.Average(); + //split it into 2 with higher than average and lower values being in one or the other respectivly + + //keep splitting till each group has 2 (account for an odd amount of numbers) + // note on this all groups must remain in order + + //sort the groups of 2 at the same time + + //combine all the groups together + + + //output result } } From ae86364a5cddc62e0e2196c09ab6c3bae42e122d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 Jan 2019 22:08:33 -0600 Subject: [PATCH 47/74] basic structure --- multithreading/Program.cs | 54 +++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index 97147f9d..5d8a59c7 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -7,20 +7,52 @@ public class Program { public static void Main() { - var results = new List { 4, 5, 10, 12, 14, 20, 1, 205, 26, 31, 120, 2, 3, 72, 40, 100, 140 }; - double average = results.Average(); + var value_to_sort = new List { 4, 5, 10, 12, 14, 20, 1, 205, 26, 31, 120, 2, 3, 72, 40, 100, 140 }; + var split_lists = SplitList(value_to_sort); + var returned_results = SplitMore(split_lists).Result; + // dont need this - var sorted_results = SortSplitValues(split_lists).Result; + string final_list = MergeSortedResults(returned_results); - //split it into 2 with higher than average and lower values being in one or the other respectivly - - //keep splitting till each group has 2 (account for an odd amount of numbers) - // note on this all groups must remain in order - - //sort the groups of 2 at the same time - - //combine all the groups together + Console.WriteLine(final_list); + } + private static object SplitList(List unsorted) + { + double average = unsorted.Average(); + var partial_sort = new ReturnedList(); + foreach (var num in unsorted) + { + if (num <= average) + { + partial_sort.less_than.Add(num); + } + else + { + partial_sort.greater_than.Add(num); + } + } + return partial_sort; + } + public static List MergeSortedResults(List nums) + { + return num; + } + public async Task> SplitMore(object nums) + { + //take in # of things to split + //loop through and do the following until there are 2 lists with 1 item each + //do this by splitting into x # of tasks with x # of tasks each. need a good peice of reusable code here. need to think about it... + //split the larger side and the smaller side at the same time + //return 4 "returned lists" then 6 then so-on + var something = new List { nums, nums }; + await Task.WhenAll(); + return something; + } - //output result + private class ReturnedList + { + public List less_than = new List(); + public List greater_than = new List(); } } From 3d000d8d8ade125c6ecbb172ea79b5b75e23c6c6 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Jan 2019 01:21:54 -0600 Subject: [PATCH 48/74] tired theres issues i can do a bubble sort in 10 min will try and complete this by class --- multithreading/Program.cs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index 5d8a59c7..cad78ba4 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -10,8 +10,7 @@ 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 }; var split_lists = SplitList(value_to_sort); var returned_results = SplitMore(split_lists).Result; - // dont need this - var sorted_results = SortSplitValues(split_lists).Result; - string final_list = MergeSortedResults(returned_results); + var final_list = MergeSortedResults(returned_results); Console.WriteLine(final_list); } @@ -32,14 +31,35 @@ private static object SplitList(List unsorted) } return partial_sort; } - public static List MergeSortedResults(List nums) + private static List MergeSortedResults(List nums) { return num; } - public async Task> SplitMore(object nums) + private async Task> SplitAgain(List numbers) + { + + } + + private async Task> SplitMore(ReturnedList numbers) { //take in # of things to split + int length = numbers.less_than.Count() + numbers.greater_than.Count(); + List split_numbers = new List { }; + List multiplied_splits = new List { }; + multiplied_splits[1] = numbers; + while (length >= split_numbers.Count()) + { + for (int i = 0; i < multiplied_splits.Count(); i++) + { + + } + } + + + + + //loop through and do the following until there are 2 lists with 1 item each //do this by splitting into x # of tasks with x # of tasks each. need a good peice of reusable code here. need to think about it... //split the larger side and the smaller side at the same time From 5e392bfb10a21ccdf10030fdccc43d67e5a178e8 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Jan 2019 01:24:13 -0600 Subject: [PATCH 49/74] . --- multithreading/Program.cs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index cad78ba4..7f68e62b 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -46,33 +46,33 @@ private async Task> SplitMore(ReturnedList numbers) //take in # of things to split int length = numbers.less_than.Count() + numbers.greater_than.Count(); List split_numbers = new List { }; - List multiplied_splits = new List { }; - multiplied_splits[1] = numbers; - while (length >= split_numbers.Count()) + split_numbers[1] = numbers; + while (length / 2 >= split_numbers.Count()) { - for (int i = 0; i < multiplied_splits.Count(); i++) + for (int i = 0; i < split_numbers.Count(); i++) { - - } + SplitAgain(split_numbers)); } + await Task.WhenAll(); + } - //loop through and do the following until there are 2 lists with 1 item each - //do this by splitting into x # of tasks with x # of tasks each. need a good peice of reusable code here. need to think about it... - //split the larger side and the smaller side at the same time - //return 4 "returned lists" then 6 then so-on - var something = new List { nums, nums }; - await Task.WhenAll(); + //loop through and do the following until there are 2 lists with 1 item each + //do this by splitting into x # of tasks with x # of tasks each. need a good peice of reusable code here. need to think about it... + //split the larger side and the smaller side at the same time + //return 4 "returned lists" then 6 then so-on + var something = new List { nums, nums }; + await Task.WhenAll(); return something; } - private class ReturnedList - { - public List less_than = new List(); - public List greater_than = new List(); - } +private class ReturnedList +{ + public List less_than = new List(); + public List greater_than = new List(); +} } From 9ca72546437d3349286f9e481da003280ffec3ab Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Jan 2019 13:31:19 -0600 Subject: [PATCH 50/74] still super broken, still working on it --- multithreading/Program.cs | 96 ++++++++++++++------------------------- 1 file changed, 35 insertions(+), 61 deletions(-) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index 7f68e62b..7fc0410e 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -3,76 +3,50 @@ using System.Collections.Generic; using System.Linq; -public class Program +namespace AsyncSort { - public static void Main() + public class Program { - var value_to_sort = new List { 4, 5, 10, 12, 14, 20, 1, 205, 26, 31, 120, 2, 3, 72, 40, 100, 140 }; - var split_lists = SplitList(value_to_sort); - var returned_results = SplitMore(split_lists).Result; - var final_list = MergeSortedResults(returned_results); - - Console.WriteLine(final_list); - } - private static object SplitList(List unsorted) - { - double average = unsorted.Average(); - var partial_sort = new ReturnedList(); - foreach (var num in unsorted) + public static void Main() { - if (num <= average) - { - partial_sort.less_than.Add(num); - } - else - { - partial_sort.greater_than.Add(num); - } - } - return partial_sort; - } - private static List MergeSortedResults(List nums) - { + var value_to_sort = new List { 4, 5, 10, 12, 14, 20, 1, 205, 26, 31, 120, 2, 3, 72, 40, 100, 140 }; + var split_lists = ReturnSortedValues(value_to_sort).results; + var final_list = MergeSortedResults(split_lists); - return num; - } - private async Task> SplitAgain(List numbers) - { + Console.WriteLine(final_list); + } - } + public static async Task SplitList(List nums) + { + var convert_too_class = new ReturnedList(); + var list_of_returns = new ReturnedObjects(); - private async Task> SplitMore(ReturnedList numbers) - { - //take in # of things to split - int length = numbers.less_than.Count() + numbers.greater_than.Count(); - List split_numbers = new List { }; - split_numbers[1] = numbers; - while (length / 2 >= split_numbers.Count()) + await (); + } + public async task ReturnSortedValues(List nums) { - for (int i = 0; i < split_numbers.Count(); i++) + double average = nums.Average(); + List results = new List(); + List return_objects = new List(); + foreach (var num in nums) { - SplitAgain(split_numbers)); + if (num > average) + { + results.less_than.add(num); + } + } } - await Task.WhenAll(); - } - - - + public class ReturnedList + { + public List less_than = new List(); + public List greater_than = new List(); + } - //loop through and do the following until there are 2 lists with 1 item each - //do this by splitting into x # of tasks with x # of tasks each. need a good peice of reusable code here. need to think about it... - //split the larger side and the smaller side at the same time - //return 4 "returned lists" then 6 then so-on - var something = new List { nums, nums }; - await Task.WhenAll(); - return something; + public class ReturnedObjects + { + public List less_than = new List(); + public List greater_than = new List(); + } } - -private class ReturnedList -{ - public List less_than = new List(); - public List greater_than = new List(); -} -} - +} \ No newline at end of file From 984ebe6a0708ff699dbc6daf6ccf1381ee654e0e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Jan 2019 16:56:39 -0600 Subject: [PATCH 51/74] have 30 min left then need to write a simple sort for home work --- multithreading/Program.cs | 89 ++++++++++++++++++++++++++++----------- 1 file changed, 64 insertions(+), 25 deletions(-) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index 7fc0410e..5bc39da8 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -7,46 +7,85 @@ 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 }; - var split_lists = ReturnSortedValues(value_to_sort).results; - var final_list = MergeSortedResults(split_lists); - - Console.WriteLine(final_list); + Program start = new Program(); + string sorted_list = start.ReturnSortedValues(value_to_sort); + Console.WriteLine(sorted_list); } - - public static async Task SplitList(List nums) + private string ReturnSortedValues(List numbers) { - var convert_too_class = new ReturnedList(); - var list_of_returns = new ReturnedObjects(); + 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; - await (); - } - public async task ReturnSortedValues(List nums) - { - double average = nums.Average(); - List results = new List(); - List return_objects = new List(); - foreach (var num in nums) + while (sort_me.lists_objects.Count != numbers.Count / 2) { - if (num > average) + var return_tasks = Sorted(sort_me).Result; + foreach (var tsk in return_tasks.task_list) { - results.less_than.add(num); + 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 class ReturnedList + public static async Task> Sorted(Objects double_me) { - public List less_than = new List(); - public List greater_than = new List(); - } + var semi_sorted = new Objects(); + semi_sorted = double_me; + var task_list = new List>(); + for (int i = 0; i > semi_sorted.lists_objects.Count; i++) + { + task_list.Add(AsyncListSort(semi_sorted.lists_object[i])); + } + await Task.WhenAll(task_list); - public class ReturnedObjects + return task_list; + } + public static async Task> AsyncListSort(List double_me) { - public List less_than = new List(); - public List greater_than = new List(); + } } } \ No newline at end of file From 2022ff3ba7fb00b2f6e56a48aee5e9b83c6ec5aa Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Jan 2019 16:56:51 -0600 Subject: [PATCH 52/74] have 30 min left then need to write a simple sort for home work --- multithreading/Program.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/multithreading/Program.cs b/multithreading/Program.cs index 5bc39da8..814e42dd 100644 --- a/multithreading/Program.cs +++ b/multithreading/Program.cs @@ -70,20 +70,23 @@ private string ReturnSortedValues(List numbers) return "print this"; } - public static async Task> Sorted(Objects double_me) + public static async Task> Sorted(Objects double_me) { var semi_sorted = new Objects(); - semi_sorted = double_me; - var task_list = new List>(); + 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(semi_sorted.lists_object[i])); + task_list.Add(AsyncListSort(simplified); } await Task.WhenAll(task_list); - return task_list; + return return_this; } - public static async Task> AsyncListSort(List double_me) + public static async Task> AsyncListSort(List> double_me) { } From 25296bab76dcd9929e61a7f4418ab8c0519d2bd4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Jan 2019 17:00:52 -0600 Subject: [PATCH 53/74] dont know what i was doing there restarting it... yayy another one down to the wire --- sort/Program.cs | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/sort/Program.cs b/sort/Program.cs index 52abfc6a..691f865e 100644 --- a/sort/Program.cs +++ b/sort/Program.cs @@ -1,5 +1,5 @@ using System; -using System.ComponentModel; + namespace sort { @@ -8,32 +8,11 @@ class Program //restarting static void Main(string[] args) { - int[] arrayToSort = new int[20] { 3, 64, 5, 6, 677, 8, 889, 44, 33, 2, 2221, 44, 55, 6, 77, 88, 89, 45, 32, 6 }; - SortArray(arrayToSort); - for (int i = 0; i < arrayToSort.Length; i++) - { - Console.Write("{0}, ", arrayToSort[i]); - } } public static void Sortparts(int[] array) { - //sort the array here - int min; - for (int i = 0; i < array.Length; i++) - { - min = i; - for (int j = 0; j < array.Length; j++) - { - if (array[j] > array[min]) - { - min = j; - int placeHolder = array[i]; - array[i] = array[min]; - } - } - } } } } From b7b7e7b4794adcfde38af22186b2ebfe944f2b9e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Jan 2019 17:09:14 -0600 Subject: [PATCH 54/74] structure doneish --- sort/Program.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sort/Program.cs b/sort/Program.cs index 691f865e..d3bc6c0e 100644 --- a/sort/Program.cs +++ b/sort/Program.cs @@ -8,11 +8,14 @@ class Program //restarting static void Main(string[] args) { + list origin_list = new list { 4, 5, 10, 12, 14, 20, 1, 205, 26, 31, 120, 2, 3, 72, 40, 100, 140 } + StartSsplitting(origin_list); } - public static void Sortparts(int[] array) + public static string StartSsplitting(list origin_list) { + } } } From 1db108473d865a703610dbbd1098566b4defe7ee Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Jan 2019 17:27:50 -0600 Subject: [PATCH 55/74] working --- sort/Program.cs | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/sort/Program.cs b/sort/Program.cs index d3bc6c0e..ad07ea45 100644 --- a/sort/Program.cs +++ b/sort/Program.cs @@ -1,21 +1,47 @@ using System; +using System.Collections.Generic; +using System.Linq; namespace sort { - class Program + public class Program { - //restarting - static void Main(string[] args) + public static void Main() { - list origin_list = new list { 4, 5, 10, 12, 14, 20, 1, 205, 26, 31, 120, 2, 3, 72, 40, 100, 140 } - StartSsplitting(origin_list); - + int[] arr = new int[15] { 213, 3, 4, 11, 20, 189, 2, 98, 90, 16, 76, 92, 123, 164, 247 }; + Sort(arr); + PrintResults(arr); } - public static string StartSsplitting(list origin_list) + 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]); } } } From c4b21c41f422b1a3aae5b794365cc2dfb88942f0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Feb 2019 15:24:49 -0600 Subject: [PATCH 56/74] almost done with checkers --- CheckersCheckpoint/.vscode/launch.json | 26 ++++ CheckersCheckpoint/.vscode/tasks.json | 15 +++ CheckersCheckpoint/Board.cs | 118 +++++++++++++++++++ CheckersCheckpoint/Checker.cs | 50 ++++++++ CheckersCheckpoint/CheckersCheckpoint.csproj | 8 ++ CheckersCheckpoint/Game.cs | 71 +++++++++++ CheckersCheckpoint/Program.cs | 14 +++ 7 files changed, 302 insertions(+) create mode 100644 CheckersCheckpoint/.vscode/launch.json create mode 100644 CheckersCheckpoint/.vscode/tasks.json create mode 100644 CheckersCheckpoint/Board.cs create mode 100644 CheckersCheckpoint/Checker.cs create mode 100644 CheckersCheckpoint/CheckersCheckpoint.csproj create mode 100644 CheckersCheckpoint/Game.cs create mode 100644 CheckersCheckpoint/Program.cs 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..c5007172 --- /dev/null +++ b/CheckersCheckpoint/Board.cs @@ -0,0 +1,118 @@ +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) + { + // Console.WriteLine(checker.Position[0] + " " + checker.Position[1]); + 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 "); + 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..e77bdba1 --- /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..f06cd63f --- /dev/null +++ b/CheckersCheckpoint/Program.cs @@ -0,0 +1,14 @@ +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 From 8091add5028fd4c6dd14e1849e9179e2766ef391 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Feb 2019 15:25:07 -0600 Subject: [PATCH 57/74] almost done with checkers --- CheckersCheckpoint/bash.exe.stackdump | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 CheckersCheckpoint/bash.exe.stackdump 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 From 9dec5fac3b522276be6440dbbaff2a4f59a17e7d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Feb 2019 15:26:55 -0600 Subject: [PATCH 58/74] almost done with checkers base --- CheckersCheckpoint/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/CheckersCheckpoint/Program.cs b/CheckersCheckpoint/Program.cs index f06cd63f..6b7c027e 100644 --- a/CheckersCheckpoint/Program.cs +++ b/CheckersCheckpoint/Program.cs @@ -10,5 +10,6 @@ public static void Main(string[] args) { new Game(); } + } } \ No newline at end of file From 1ef1583aa18b9f6f27c8d262a97735adfc835daa Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Feb 2019 15:47:39 -0600 Subject: [PATCH 59/74] base done prints checkers had an issue with console Encoding solved on board line 92 --- CheckersCheckpoint/Board.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/CheckersCheckpoint/Board.cs b/CheckersCheckpoint/Board.cs index c5007172..4e30bbdc 100644 --- a/CheckersCheckpoint/Board.cs +++ b/CheckersCheckpoint/Board.cs @@ -89,6 +89,7 @@ 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])); From cacb3e752e441417c14bad1fab7ebc163a688663 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Feb 2019 18:25:50 -0600 Subject: [PATCH 60/74] rudimentary checkers done --- CheckersCheckpoint/Board.cs | 14 +++----------- CheckersCheckpoint/Checker.cs | 4 ++-- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/CheckersCheckpoint/Board.cs b/CheckersCheckpoint/Board.cs index 4e30bbdc..917421dc 100644 --- a/CheckersCheckpoint/Board.cs +++ b/CheckersCheckpoint/Board.cs @@ -15,16 +15,8 @@ public Board() this.CreateBoard(); return; } - public string[][] Grid - { - get; - set; - } - public List Checkers - { - get; - set; - } + public string[][] Grid { get; set; } + public List Checkers { get; set; } public void CreateBoard() @@ -77,7 +69,7 @@ public void PlaceCheckers() { foreach (var checker in Checkers) { - // Console.WriteLine(checker.Position[0] + " " + checker.Position[1]); + ; this.Grid[checker.Position[0]][checker.Position[1]] = checker.Symbol; } return; diff --git a/CheckersCheckpoint/Checker.cs b/CheckersCheckpoint/Checker.cs index e77bdba1..6b687ce0 100644 --- a/CheckersCheckpoint/Checker.cs +++ b/CheckersCheckpoint/Checker.cs @@ -17,12 +17,12 @@ public Checker(string color, int[] position) if (color == "white") { - circleId = int.Parse(" 25CE", System.Globalization.NumberStyles.HexNumber); + circleId = int.Parse("25CE", System.Globalization.NumberStyles.HexNumber); Color = "white"; } else { - circleId = int.Parse(" 25C9", System.Globalization.NumberStyles.HexNumber); + circleId = int.Parse("25C9", System.Globalization.NumberStyles.HexNumber); Color = "black"; } this.Symbol = char.ConvertFromUtf32(circleId); From b2a16a5d981727e608f191447a4b2528918e555f Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 2 Mar 2019 00:34:06 -0600 Subject: [PATCH 61/74] base setup --- NewCheckers/.vscode/launch.json | 26 +++++++++++++++++++++++ NewCheckers/.vscode/tasks.json | 15 +++++++++++++ NewCheckers/Board.cs | 37 +++++++++++++++++++++++++++++++++ NewCheckers/Checker.cs | 18 ++++++++++++++++ NewCheckers/Coordinates.cs | 15 +++++++++++++ NewCheckers/Game.cs | 9 ++++++++ NewCheckers/NewCheckers.csproj | 8 +++++++ NewCheckers/Program.cs | 12 +++++++++++ 8 files changed, 140 insertions(+) create mode 100644 NewCheckers/.vscode/launch.json create mode 100644 NewCheckers/.vscode/tasks.json create mode 100644 NewCheckers/Board.cs create mode 100644 NewCheckers/Checker.cs create mode 100644 NewCheckers/Coordinates.cs create mode 100644 NewCheckers/Game.cs create mode 100644 NewCheckers/NewCheckers.csproj create mode 100644 NewCheckers/Program.cs 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..4868b07f --- /dev/null +++ b/NewCheckers/Board.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; + +namespace NewCheckers +{ + public class Board + { + public Dictionary pieces { get; set; } = new Dictionary(); + + public void board() + { + pieces = new Dictionary(); + } + public static void MoveChecker(Checker piece, Coordinates cords) + { + CheckValidity(piece, cords); + } + private static bool CheckValidity(Checker piece, Coordinates cords) + { + bool valid = false; + bool direction = CheckDirection(piece, cords); + bool space = CheckSpace(piece, cords); + valid = direction && space ? true : false; + return valid; + } + private static bool CheckDirection(Checker piece, Coordinates cords) + { + bool valid = false; + return valid; + } + private static bool CheckSpace(Checker piece, Coordinates cords) + { + bool valid = false; + return valid; + } + } +} diff --git a/NewCheckers/Checker.cs b/NewCheckers/Checker.cs new file mode 100644 index 00000000..e6ffe5df --- /dev/null +++ b/NewCheckers/Checker.cs @@ -0,0 +1,18 @@ +using System; + +namespace NewCheckers +{ + public class Checker + { + public string Color { get; private set; } + public bool King { get; private set; } = false; + public Checker(string color) + { + Color = color == "white" ? "25ce" : "25c9"; + } + public void MakeKing() + { + King = true; + } + } +} diff --git a/NewCheckers/Coordinates.cs b/NewCheckers/Coordinates.cs new file mode 100644 index 00000000..47ffa40c --- /dev/null +++ b/NewCheckers/Coordinates.cs @@ -0,0 +1,15 @@ +using System; + +namespace NewCheckers +{ + public class Coordinates + { + public int X { get; private set; } + public int Y { get; private set; } + public Coordinates(int x, int y) + { + X = x; + Y = y; + } + } +} diff --git a/NewCheckers/Game.cs b/NewCheckers/Game.cs new file mode 100644 index 00000000..46fab4db --- /dev/null +++ b/NewCheckers/Game.cs @@ -0,0 +1,9 @@ +using System; + +namespace NewCheckers +{ + public class Game + { + //request both moves + } +} \ No newline at end of file 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..e271caa4 --- /dev/null +++ b/NewCheckers/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace NewCheckers +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} From 41194d02483f44f946eecf3e56883a047e94ae04 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 2 Mar 2019 00:34:15 -0600 Subject: [PATCH 62/74] base setup --- NewCheckers/Board.cs | 9 +++++++-- NewCheckers/Checker.cs | 3 ++- NewCheckers/Game.cs | 2 +- NewCheckers/Program.cs | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/NewCheckers/Board.cs b/NewCheckers/Board.cs index 4868b07f..cea5b10e 100644 --- a/NewCheckers/Board.cs +++ b/NewCheckers/Board.cs @@ -13,11 +13,16 @@ public void board() } public static void MoveChecker(Checker piece, Coordinates cords) { - CheckValidity(piece, cords); + bool validChecker = CheckValidity(piece, cords); + if (validChecker) + { + + } } - private static bool CheckValidity(Checker piece, Coordinates cords) + private static bool CheckValidity(Checker piece, Coordinates cords, int PlayerTurn) { bool valid = false; + bool validChecker = IsCheckerValid(PlayerTurn, piece) bool direction = CheckDirection(piece, cords); bool space = CheckSpace(piece, cords); valid = direction && space ? true : false; diff --git a/NewCheckers/Checker.cs b/NewCheckers/Checker.cs index e6ffe5df..f921e765 100644 --- a/NewCheckers/Checker.cs +++ b/NewCheckers/Checker.cs @@ -5,9 +5,10 @@ namespace NewCheckers public class Checker { public string Color { get; private set; } - public bool King { get; private set; } = false; + public bool King { get; private set; } public Checker(string color) { + King = false; Color = color == "white" ? "25ce" : "25c9"; } public void MakeKing() diff --git a/NewCheckers/Game.cs b/NewCheckers/Game.cs index 46fab4db..a94241d7 100644 --- a/NewCheckers/Game.cs +++ b/NewCheckers/Game.cs @@ -4,6 +4,6 @@ namespace NewCheckers { public class Game { - //request both moves + //request both moves controle board } } \ No newline at end of file diff --git a/NewCheckers/Program.cs b/NewCheckers/Program.cs index e271caa4..99a62ada 100644 --- a/NewCheckers/Program.cs +++ b/NewCheckers/Program.cs @@ -6,7 +6,8 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + Game game = new Game(); + game.Run(); } } } From abfef1caa9ef2108e9ff2bd5fb3c2f8b67c5e37c Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 2 Mar 2019 00:43:09 -0600 Subject: [PATCH 63/74] base setup --- NewCheckers/Board.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/NewCheckers/Board.cs b/NewCheckers/Board.cs index cea5b10e..556b1e8e 100644 --- a/NewCheckers/Board.cs +++ b/NewCheckers/Board.cs @@ -11,9 +11,9 @@ public void board() { pieces = new Dictionary(); } - public static void MoveChecker(Checker piece, Coordinates cords) + public static void MoveChecker(Checker piece, Coordinates cords, int PlayerTurn) { - bool validChecker = CheckValidity(piece, cords); + bool validChecker = CheckValidity(piece, cords, PlayerTurn); if (validChecker) { @@ -22,20 +22,28 @@ public static void MoveChecker(Checker piece, Coordinates cords) private static bool CheckValidity(Checker piece, Coordinates cords, int PlayerTurn) { bool valid = false; - bool validChecker = IsCheckerValid(PlayerTurn, piece) + bool validChecker = IsCheckerValid(PlayerTurn, piece); bool direction = CheckDirection(piece, cords); bool space = CheckSpace(piece, cords); valid = direction && space ? true : false; return valid; } + private static bool IsCheckerValid(int turn, Checker piece) + { + bool valid = false; + //check checker + return valid; + } private static bool CheckDirection(Checker piece, Coordinates cords) { bool valid = false; + //check direction validity return valid; } private static bool CheckSpace(Checker piece, Coordinates cords) { bool valid = false; + // check landing space validity return valid; } } From 8cd423e94ba8b5d95144d6748e018bc615562602 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 3 Mar 2019 01:49:58 -0600 Subject: [PATCH 64/74] almost have the board setup --- NewCheckers/Board.cs | 69 ++++++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 19 deletions(-) diff --git a/NewCheckers/Board.cs b/NewCheckers/Board.cs index 556b1e8e..a5ed99bd 100644 --- a/NewCheckers/Board.cs +++ b/NewCheckers/Board.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; namespace NewCheckers { @@ -10,40 +11,70 @@ public class Board public void board() { pieces = new Dictionary(); + CreateCheckers buildNew = new CreateCheckers(); + pieces = buildNew.InitialCheckers(); } - public static void MoveChecker(Checker piece, Coordinates cords, int PlayerTurn) + + public void ChooseMove(int PlayerTurn) { - bool validChecker = CheckValidity(piece, cords, PlayerTurn); - if (validChecker) + int row = PickRow(); + int column = PickColumn(); + Coordinates from = new Coordinates(row, column); + Checker result; + if (pieces.TryGetValue(from, out result)) { - + if (PlayerTurn == 0 && result.Color == "25ce") + { + int toRow = PickRow(); + int toColumn = PickColumn(); + Coordinates to = new Coordinates(toRow, toColumn); + bool valid = CheckValidity(to, from); + if (valid) + { + pieces[to] = pieces[from]; + pieces[from] = null; + } + } + else if (PlayerTurn == 1 && result.Color == "25c9") + { + int toRow = PickRow(); + int toColumn = PickColumn(); + Coordinates to = new Coordinates(toRow, toColumn); + bool valid = CheckValidity(to, from); + if (valid) + { + pieces[to] = pieces[from]; + pieces[from] = null; + } + } + else + { + Console.Clear(); + Console.WriteLine("Invalid Selection."); + Thread.Sleep(500); + } } + + //if this "cords" (row/column) contains a checker of the Player whos turn this is initiate move checker } - private static bool CheckValidity(Checker piece, Coordinates cords, int PlayerTurn) - { - bool valid = false; - bool validChecker = IsCheckerValid(PlayerTurn, piece); - bool direction = CheckDirection(piece, cords); - bool space = CheckSpace(piece, cords); - valid = direction && space ? true : false; - return valid; - } - private static bool IsCheckerValid(int turn, Checker piece) + private static bool CheckValidity(Coordinates to, Coordinates from) { bool valid = false; - //check checker + bool validDirection = CheckDirection(to, from); + bool space = CheckLanding(to, from); + valid = validDirection && space ? true : false; return valid; } - private static bool CheckDirection(Checker piece, Coordinates cords) + private static bool CheckDirection(Coordinates to, Coordinates from) { bool valid = false; - //check direction validity + //check direction validity. king? if yes can go backwards, player 1 goes one way 2 the other return valid; } - private static bool CheckSpace(Checker piece, Coordinates cords) + private static bool CheckLanding(Coordinates to, Coordinates from) { bool valid = false; - // check landing space validity + // check landing space validity is another checker already here, is it a valid space return valid; } } From a8e94a3079d52593259cad7f19fa7ff82fdb72d0 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 3 Mar 2019 20:09:02 -0600 Subject: [PATCH 65/74] worked on game logic a bit more still have no display --- NewCheckers/Board.cs | 18 +++++++++++------- NewCheckers/Checker.cs | 6 +++--- NewCheckers/Coordinates.cs | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/NewCheckers/Board.cs b/NewCheckers/Board.cs index a5ed99bd..0e87f23b 100644 --- a/NewCheckers/Board.cs +++ b/NewCheckers/Board.cs @@ -6,13 +6,14 @@ namespace NewCheckers { public class Board { - public Dictionary pieces { get; set; } = new Dictionary(); + public Dictionary pieces { get; set; } + public static Dictionary StaticBoard { get; set; } public void board() { - pieces = new Dictionary(); + this.pieces = new Dictionary(); CreateCheckers buildNew = new CreateCheckers(); - pieces = buildNew.InitialCheckers(); + this.pieces = buildNew.InitialCheckers(); } public void ChooseMove(int PlayerTurn) @@ -28,11 +29,12 @@ public void ChooseMove(int PlayerTurn) int toRow = PickRow(); int toColumn = PickColumn(); Coordinates to = new Coordinates(toRow, toColumn); + StaticBoard = pieces; bool valid = CheckValidity(to, from); if (valid) { - pieces[to] = pieces[from]; - pieces[from] = null; + this.pieces[to] = pieces[from]; + this.pieces[from] = null; } } else if (PlayerTurn == 1 && result.Color == "25c9") @@ -40,11 +42,12 @@ public void ChooseMove(int PlayerTurn) int toRow = PickRow(); int toColumn = PickColumn(); Coordinates to = new Coordinates(toRow, toColumn); + StaticBoard = pieces; bool valid = CheckValidity(to, from); if (valid) { - pieces[to] = pieces[from]; - pieces[from] = null; + this.pieces[to] = pieces[from]; + this.pieces[from] = null; } } else @@ -68,6 +71,7 @@ private static bool CheckValidity(Coordinates to, Coordinates from) private static bool CheckDirection(Coordinates to, Coordinates from) { bool valid = false; + bool isKing = StaticBoard[to].King; //check direction validity. king? if yes can go backwards, player 1 goes one way 2 the other return valid; } diff --git a/NewCheckers/Checker.cs b/NewCheckers/Checker.cs index f921e765..e194e1ec 100644 --- a/NewCheckers/Checker.cs +++ b/NewCheckers/Checker.cs @@ -8,12 +8,12 @@ public class Checker public bool King { get; private set; } public Checker(string color) { - King = false; - Color = color == "white" ? "25ce" : "25c9"; + this.King = false; + this.Color = color == "white" ? "25ce" : "25c9"; } public void MakeKing() { - King = true; + this.King = true; } } } diff --git a/NewCheckers/Coordinates.cs b/NewCheckers/Coordinates.cs index 47ffa40c..8b36481f 100644 --- a/NewCheckers/Coordinates.cs +++ b/NewCheckers/Coordinates.cs @@ -8,8 +8,8 @@ public class Coordinates public int Y { get; private set; } public Coordinates(int x, int y) { - X = x; - Y = y; + this.X = x; + this.Y = y; } } } From 7363468899cb0fd86ab195c1060b70a6a704a068 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 3 Mar 2019 20:09:14 -0600 Subject: [PATCH 66/74] worked on game logic a bit more still have no display --- NewCheckers/Board.cs | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/NewCheckers/Board.cs b/NewCheckers/Board.cs index 0e87f23b..fd2efacd 100644 --- a/NewCheckers/Board.cs +++ b/NewCheckers/Board.cs @@ -7,7 +7,6 @@ namespace NewCheckers public class Board { public Dictionary pieces { get; set; } - public static Dictionary StaticBoard { get; set; } public void board() { @@ -29,10 +28,11 @@ public void ChooseMove(int PlayerTurn) int toRow = PickRow(); int toColumn = PickColumn(); Coordinates to = new Coordinates(toRow, toColumn); - StaticBoard = pieces; - bool valid = CheckValidity(to, from); + CheckMoveValidity check = new CheckMoveValidity(pieces); + bool valid = check.Validity(to, from); if (valid) { + pieces[check.RemoveMe.X, check.RemoveMe.Y] this.pieces[to] = pieces[from]; this.pieces[from] = null; } @@ -42,8 +42,8 @@ public void ChooseMove(int PlayerTurn) int toRow = PickRow(); int toColumn = PickColumn(); Coordinates to = new Coordinates(toRow, toColumn); - StaticBoard = pieces; - bool valid = CheckValidity(to, from); + CheckMoveValidity check = new CheckMoveValidity(pieces); + bool valid = check.Validity(to, from); if (valid) { this.pieces[to] = pieces[from]; @@ -60,26 +60,5 @@ public void ChooseMove(int PlayerTurn) //if this "cords" (row/column) contains a checker of the Player whos turn this is initiate move checker } - private static bool CheckValidity(Coordinates to, Coordinates from) - { - bool valid = false; - bool validDirection = CheckDirection(to, from); - bool space = CheckLanding(to, from); - valid = validDirection && space ? true : false; - return valid; - } - private static bool CheckDirection(Coordinates to, Coordinates from) - { - bool valid = false; - bool isKing = StaticBoard[to].King; - //check direction validity. king? if yes can go backwards, player 1 goes one way 2 the other - return valid; - } - private static bool CheckLanding(Coordinates to, Coordinates from) - { - bool valid = false; - // check landing space validity is another checker already here, is it a valid space - return valid; - } } } From c1804f9f5468a614082d176b52a82c43913b3075 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Mar 2019 18:33:20 -0600 Subject: [PATCH 67/74] fi8nished board --- NewCheckers/Board.cs | 121 +++++++++++++++++++++++-------------- NewCheckers/Checker.cs | 16 ++++- NewCheckers/Coordinates.cs | 2 +- NewCheckers/Game.cs | 23 +++++++ 4 files changed, 115 insertions(+), 47 deletions(-) diff --git a/NewCheckers/Board.cs b/NewCheckers/Board.cs index fd2efacd..4fc5b7ce 100644 --- a/NewCheckers/Board.cs +++ b/NewCheckers/Board.cs @@ -8,57 +8,90 @@ public class Board { public Dictionary pieces { get; set; } - public void board() + public Board() { - this.pieces = new Dictionary(); - CreateCheckers buildNew = new CreateCheckers(); - this.pieces = buildNew.InitialCheckers(); - } - - public void ChooseMove(int PlayerTurn) - { - int row = PickRow(); - int column = PickColumn(); - Coordinates from = new Coordinates(row, column); - Checker result; - if (pieces.TryGetValue(from, out result)) + pieces = new Dictionary(); + for (int i = 0; i < 8; i++) { - if (PlayerTurn == 0 && result.Color == "25ce") + for (int j = 0; j < 8; j++) { - int toRow = PickRow(); - int toColumn = PickColumn(); - Coordinates to = new Coordinates(toRow, toColumn); - CheckMoveValidity check = new CheckMoveValidity(pieces); - bool valid = check.Validity(to, from); - if (valid) + Coordinates cord = new Coordinates(i, j); + Checker check = null; + switch (i) { - pieces[check.RemoveMe.X, check.RemoveMe.Y] - this.pieces[to] = pieces[from]; - this.pieces[from] = null; + 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; } } - else if (PlayerTurn == 1 && result.Color == "25c9") - { - int toRow = PickRow(); - int toColumn = PickColumn(); - Coordinates to = new Coordinates(toRow, toColumn); - CheckMoveValidity check = new CheckMoveValidity(pieces); - bool valid = check.Validity(to, from); - if (valid) - { - this.pieces[to] = pieces[from]; - this.pieces[from] = null; - } - } - else - { - Console.Clear(); - Console.WriteLine("Invalid Selection."); - Thread.Sleep(500); - } } - - //if this "cords" (row/column) contains a checker of the Player whos turn this is initiate move checker } } } + diff --git a/NewCheckers/Checker.cs b/NewCheckers/Checker.cs index e194e1ec..a4bfb23b 100644 --- a/NewCheckers/Checker.cs +++ b/NewCheckers/Checker.cs @@ -5,11 +5,23 @@ 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) { - this.King = false; - this.Color = color == "white" ? "25ce" : "25c9"; + 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() { diff --git a/NewCheckers/Coordinates.cs b/NewCheckers/Coordinates.cs index 8b36481f..ff0b1818 100644 --- a/NewCheckers/Coordinates.cs +++ b/NewCheckers/Coordinates.cs @@ -2,7 +2,7 @@ namespace NewCheckers { - public class Coordinates + public struct Coordinates { public int X { get; private set; } public int Y { get; private set; } diff --git a/NewCheckers/Game.cs b/NewCheckers/Game.cs index a94241d7..bd266165 100644 --- a/NewCheckers/Game.cs +++ b/NewCheckers/Game.cs @@ -5,5 +5,28 @@ namespace NewCheckers public class Game { //request both moves controle board + Board CurrentBoard; + public Game() + { + CurrentBoard = new Board(); + } + 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(); + bool valid = Choose.CheckValidity(moveFrom, moveTo); + Display disp = new Display(CurrentBoard.pieces); + //disp.printBoard(); + int one = disp.ChooseX(1); + int two = disp.ChooseY(1, one); + Console.WriteLine(one + "," + two); + } + } } } \ No newline at end of file From bb0af5a017ba3b6d2d1a1c87b70b4490fefdf6e1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Mar 2019 18:41:16 -0600 Subject: [PATCH 68/74] fi8nished board --- NewCheckers/CheckLanding.cs | 47 +++++++ NewCheckers/CreateCheckers.cs | 14 ++ NewCheckers/Display.cs | 256 ++++++++++++++++++++++++++++++++++ NewCheckers/IsValid.cs | 54 +++++++ NewCheckers/Select.cs | 37 +++++ 5 files changed, 408 insertions(+) create mode 100644 NewCheckers/CheckLanding.cs create mode 100644 NewCheckers/CreateCheckers.cs create mode 100644 NewCheckers/Display.cs create mode 100644 NewCheckers/IsValid.cs create mode 100644 NewCheckers/Select.cs diff --git a/NewCheckers/CheckLanding.cs b/NewCheckers/CheckLanding.cs new file mode 100644 index 00000000..e3faa549 --- /dev/null +++ b/NewCheckers/CheckLanding.cs @@ -0,0 +1,47 @@ +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; + + foreach (var item in possibles) + { + if (item.X == to.X && item.Y == to.Y) + { + isValidLanding = true; + } + } + if (isValidLanding) + { + if (toX - 2 == x || ) + } + + } + } +} \ No newline at end of file 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..7392476c --- /dev/null +++ b/NewCheckers/Display.cs @@ -0,0 +1,256 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NewCheckers +{ + public class Display + { + public Dictionary pieces { get; set; } + private int index = 0; + 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)//ChooseX + { + 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.Red; + 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; + } + else + { + Console.BackgroundColor = ConsoleColor.Black; + } + } + else + { + if (j == 0 || j % 2 == 0) + { + Console.BackgroundColor = ConsoleColor.Black; + } + else + { + Console.BackgroundColor = ConsoleColor.White; + } + } + 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)//PickY + { + 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; + } + else + { + Console.BackgroundColor = ConsoleColor.Black; + } + if (i == x && j == index) + { + Console.BackgroundColor = ConsoleColor.Green; + } + } + else + { + if (j == 0 || j % 2 == 0) + { + Console.BackgroundColor = ConsoleColor.Black; + } + else + { + Console.BackgroundColor = ConsoleColor.White; + } + 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.Red; + 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/IsValid.cs b/NewCheckers/IsValid.cs new file mode 100644 index 00000000..66e17a1e --- /dev/null +++ b/NewCheckers/IsValid.cs @@ -0,0 +1,54 @@ +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 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 = CheckFrom(); + bool isToValid = CheckTo(); + this.Valid = isFromValid && isToValid ? true : false; + return Valid; + } + private bool CheckFrom() + { + bool from; + if (Turn == 1 && CurBoard[From].ColorAbs == "white") + { + from = true; + } + else if (Turn == 2 && CurBoard[From].ColorAbs == "black") + { + from = true; + } + else + { + from = false; + } + return from; + } + private bool CheckTo() + { + bool to = false; + CheckLanding land = new CheckLanding(); + land.Run(From, To, CurBoard); + return to; + } + + } +} diff --git a/NewCheckers/Select.cs b/NewCheckers/Select.cs new file mode 100644 index 00000000..fdff344e --- /dev/null +++ b/NewCheckers/Select.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Threading; + +namespace NewCheckers +{ + public class Select + { + private Dictionary CurBoard; + private int Turn; + public Select(int currentTurn, Dictionary CurrentBoard) + { + CurBoard = CurrentBoard; + Turn = currentTurn; + } + public Coordinates From() + { + Display display = new Display(CurBoard); + int row = display.ChooseX(Turn); + int column = display.ChooseY(Turn, row); + return new Coordinates(row, column); + } + public Coordinates To() + { + Display display = new Display(CurBoard); + int row = display.ChooseX(Turn); + int column = display.ChooseY(Turn, row); + return new Coordinates(row, column); + } + public bool CheckValidity(Coordinates from, Coordinates to) + { + IsValid isValid = new IsValid(Turn, CurBoard, from, to); + bool valid = isValid.Check(); + return valid; + } + } +} \ No newline at end of file From 329981b4b2d36d1fc8d816a437006dff4f801725 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Mar 2019 18:41:52 -0600 Subject: [PATCH 69/74] fi8nished board --- NewCheckers/CheckLanding.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NewCheckers/CheckLanding.cs b/NewCheckers/CheckLanding.cs index e3faa549..17271576 100644 --- a/NewCheckers/CheckLanding.cs +++ b/NewCheckers/CheckLanding.cs @@ -39,7 +39,9 @@ public bool Run(Coordinates from, Coordinates to, Dictionary Date: Tue, 5 Mar 2019 01:11:55 -0600 Subject: [PATCH 70/74] finished for now have issues with being king or not --- NewCheckers/CheckLanding.cs | 56 +++++++++++++++++++++-- NewCheckers/Display.cs | 89 +++++++++++++++++++++++++++++++++++-- NewCheckers/Game.cs | 50 ++++++++++++++++++--- NewCheckers/IsValid.cs | 57 +++++++++++++++++++++--- NewCheckers/Select.cs | 21 ++++++--- 5 files changed, 247 insertions(+), 26 deletions(-) diff --git a/NewCheckers/CheckLanding.cs b/NewCheckers/CheckLanding.cs index 17271576..f692633f 100644 --- a/NewCheckers/CheckLanding.cs +++ b/NewCheckers/CheckLanding.cs @@ -5,8 +5,10 @@ namespace NewCheckers { public class CheckLanding { - public Coordinates remove { get; set; } + public Coordinates Remove { get; set; } public bool Jumped { get; set; } = false; + + public CheckLanding() { Jumped = false; @@ -29,21 +31,69 @@ public bool Run(Coordinates from, Coordinates to, Dictionary pieces { get; set; } private int index = 0; + private Boolean Second = false; + private Coordinates cordsPrior; public Display(Dictionary board) { pieces = new Dictionary(); @@ -32,8 +34,19 @@ public Display(Dictionary board) } } } - public int ChooseX(int player)//ChooseX + 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 = ""; @@ -47,7 +60,7 @@ public int ChooseX(int player)//ChooseX if (index == i) { Console.BackgroundColor = ConsoleColor.Black; - Console.ForegroundColor = ConsoleColor.Red; + Console.ForegroundColor = ConsoleColor.Green; Console.Write(i); Console.Write(" "); } @@ -66,10 +79,24 @@ public int ChooseX(int player)//ChooseX 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 @@ -77,10 +104,24 @@ public int ChooseX(int player)//ChooseX 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 = ""; @@ -92,6 +133,7 @@ public int ChooseX(int player)//ChooseX { value = char.ConvertFromUtf32(int.Parse("25CF", System.Globalization.NumberStyles.HexNumber)); Console.ForegroundColor = ConsoleColor.Red; + Console.Write(value); Console.Write(" "); } @@ -135,8 +177,19 @@ private string MenuControllerX(List items) Console.Clear(); return ""; } - public int ChooseY(int player, int x)//PickY + 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 = ""; @@ -156,10 +209,24 @@ public int ChooseY(int player, int x)//PickY 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) { @@ -171,10 +238,24 @@ public int ChooseY(int player, int x)//PickY 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) { @@ -214,7 +295,7 @@ public int ChooseY(int player, int x)//PickY if (index == i) { Console.BackgroundColor = ConsoleColor.Black; - Console.ForegroundColor = ConsoleColor.Red; + Console.ForegroundColor = ConsoleColor.Green; Console.Write(" "); Console.Write(items[i]); Console.Write(" "); diff --git a/NewCheckers/Game.cs b/NewCheckers/Game.cs index bd266165..9f3b885b 100644 --- a/NewCheckers/Game.cs +++ b/NewCheckers/Game.cs @@ -10,6 +10,8 @@ public Game() { CurrentBoard = new Board(); } + public int White = 0; + public int Black = 0; public void Run() { int turn = 1; @@ -19,14 +21,48 @@ public void Run() { Select Choose = new Select(turn, CurrentBoard.pieces); Coordinates moveFrom = Choose.From(); - Coordinates moveTo = Choose.To(); + Coordinates moveTo = Choose.To(moveFrom); bool valid = Choose.CheckValidity(moveFrom, moveTo); - Display disp = new Display(CurrentBoard.pieces); - //disp.printBoard(); - int one = disp.ChooseX(1); - int two = disp.ChooseY(1, one); - Console.WriteLine(one + "," + two); + + 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; + } + } } } -} \ No newline at end of file +} +/*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 index 66e17a1e..56923edb 100644 --- a/NewCheckers/IsValid.cs +++ b/NewCheckers/IsValid.cs @@ -10,7 +10,8 @@ public class IsValid private Coordinates From; private Coordinates To; public bool Valid = false; - public Coordinates remove; + public Coordinates Remove; + public bool Jumped = false; public IsValid(int turn, Dictionary curBoard, Coordinates from, Coordinates to) { this.CurBoard = curBoard; @@ -20,19 +21,21 @@ public IsValid(int turn, Dictionary curBoard, Coordinates } public bool Run() { - bool isFromValid = CheckFrom(); - bool isToValid = CheckTo(); + 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].ColorAbs == "white") + if (Turn == 1 && CurBoard[From] != null && CurBoard[From].ColorAbs == "white") { from = true; } - else if (Turn == 2 && CurBoard[From].ColorAbs == "black") + else if (Turn == 2 && CurBoard[From] != null && CurBoard[From].ColorAbs == "black") { from = true; } @@ -46,7 +49,49 @@ private bool CheckTo() { bool to = false; CheckLanding land = new CheckLanding(); - land.Run(From, To, CurBoard); + 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/Select.cs b/NewCheckers/Select.cs index fdff344e..05f35731 100644 --- a/NewCheckers/Select.cs +++ b/NewCheckers/Select.cs @@ -8,6 +8,8 @@ public class Select { private Dictionary CurBoard; private int Turn; + public bool Jumped = false; + public Coordinates Remove; public Select(int currentTurn, Dictionary CurrentBoard) { CurBoard = CurrentBoard; @@ -16,21 +18,28 @@ public Select(int currentTurn, Dictionary CurrentBoard) public Coordinates From() { Display display = new Display(CurBoard); - int row = display.ChooseX(Turn); - int column = display.ChooseY(Turn, row); + int row = display.ChooseX(Turn, null, null); + int column = display.ChooseY(Turn, row, null, null); return new Coordinates(row, column); } - public Coordinates To() + 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); - int column = display.ChooseY(Turn, row); + 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.Check(); + bool valid = isValid.Run(); + if (isValid.Jumped) + { + this.Jumped = true; + this.Remove = isValid.Remove; + } return valid; } } From 2d4debc6a352f92fb54fffadabad95055349ce1e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 5 Mar 2019 18:23:04 -0600 Subject: [PATCH 71/74] added king system --- NewCheckers/Game.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/NewCheckers/Game.cs b/NewCheckers/Game.cs index 9f3b885b..e17f3317 100644 --- a/NewCheckers/Game.cs +++ b/NewCheckers/Game.cs @@ -58,7 +58,6 @@ public void Run() { Winner = White == 12 ? 1 : 2; } - } } } From aea114ad75145965543b8773d0a8a87d9339ad7b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 5 Mar 2019 19:28:14 -0600 Subject: [PATCH 72/74] 0 --- NewCheckers/IsValid.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/NewCheckers/IsValid.cs b/NewCheckers/IsValid.cs index 56923edb..2079920c 100644 --- a/NewCheckers/IsValid.cs +++ b/NewCheckers/IsValid.cs @@ -70,7 +70,13 @@ private bool CheckTo() } else { - to = false; + if (tryMe != null) + { + if (!tryMe.King) + { + to = false; + } + } } } if (Turn == 2 && (To.X - From.X) < 0) From 5eb441f7f8afb2643cbc1ca4067c73b1780979bd Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 5 Mar 2019 19:30:48 -0600 Subject: [PATCH 73/74] 0 --- NewCheckers/IsValid.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/NewCheckers/IsValid.cs b/NewCheckers/IsValid.cs index 2079920c..ee96a584 100644 --- a/NewCheckers/IsValid.cs +++ b/NewCheckers/IsValid.cs @@ -58,7 +58,8 @@ private bool CheckTo() if (Turn == 1 && (From.X - To.X) < 0) { Checker tryMe; - if (!CurBoard.TryGetValue(From, out tryMe)) + + if (CurBoard.TryGetValue(From, out tryMe)) { if (tryMe != null) { @@ -70,19 +71,13 @@ private bool CheckTo() } else { - if (tryMe != null) - { - if (!tryMe.King) - { - to = false; - } - } + to = false; } } if (Turn == 2 && (To.X - From.X) < 0) { Checker tryMe; - if (!CurBoard.TryGetValue(From, out tryMe)) + if (CurBoard.TryGetValue(From, out tryMe)) { if (tryMe != null && !tryMe.King) if (tryMe != null) From 124fb2327e89311ee8f965e50506edfa998830c3 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Mar 2019 21:22:26 -0600 Subject: [PATCH 74/74] forcing me to commit nothing --- NewCheckers/IsValid.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/NewCheckers/IsValid.cs b/NewCheckers/IsValid.cs index ee96a584..bdb5a0c9 100644 --- a/NewCheckers/IsValid.cs +++ b/NewCheckers/IsValid.cs @@ -58,7 +58,6 @@ private bool CheckTo() if (Turn == 1 && (From.X - To.X) < 0) { Checker tryMe; - if (CurBoard.TryGetValue(From, out tryMe)) { if (tryMe != null)