From 678be69e327762165f9664c53a388da61ad3bea3 Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Mon, 7 Jan 2019 20:40:29 -0600 Subject: [PATCH 01/19] Saying hello to myself --- HelloWorld/HelloWorld.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/HelloWorld/HelloWorld.cs b/HelloWorld/HelloWorld.cs index 8168c805..185d81a7 100644 --- a/HelloWorld/HelloWorld.cs +++ b/HelloWorld/HelloWorld.cs @@ -5,8 +5,12 @@ namespace HelloWorld class Program { static void Main(string[] args) - { - Console.WriteLine("Hello World!"); + { + + Console.WriteLine("Hello Kristian!"); + string yourName = Console.ReadLine(); + + } } } From 158d5c6eee5a462b17963b61ffe8a0a0f7c016d9 Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Wed, 9 Jan 2019 19:14:13 -0600 Subject: [PATCH 02/19] Saying hello to myself --- HelloWorld/HelloWorld.cs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/HelloWorld/HelloWorld.cs b/HelloWorld/HelloWorld.cs index 185d81a7..05429f85 100644 --- a/HelloWorld/HelloWorld.cs +++ b/HelloWorld/HelloWorld.cs @@ -1,16 +1,25 @@ using System; -namespace HelloWorld +public class Program { - class Program + public static void Main() { - static void Main(string[] args) - { + string name = ""; + int age = 0; + int year = 0; + - Console.WriteLine("Hello Kristian!"); - string yourName = Console.ReadLine(); + 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 c08b948c542ce9c61257c8efd0be92bc22901afb Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Wed, 16 Jan 2019 17:23:03 -0600 Subject: [PATCH 03/19] TextBasedGame --- PigLatin/PigLatin.cs | 11 ++ TextBasedGame/.vscode/launch.json | 26 ++++ TextBasedGame/.vscode/tasks.json | 15 +++ TextBasedGame/Program.cs | 197 +++++++++++++++++++++++++++++ TextBasedGame/TextBasedGame.csproj | 8 ++ 5 files changed, 257 insertions(+) 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/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index 702647dd..10961fd7 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -7,6 +7,17 @@ class Program public static void Main() { // your code goes here + string alphabet = "abcdefghijklmnopqrstuvwxyz"; + string firstThird = alphabet.Substring(0, 8); + string secondThird = alphabet.Substring(8, 8); + string thirdThird = alphabet.Substring(17); + + Console.WriteLine("First Third: " + firstThird); + Console.WriteLine("Second Third: " + secondThird); + Console.WriteLine("Third Third: " + thirdThird); + + + // leave this command at the end so your program does not close automatically Console.ReadLine(); diff --git a/TextBasedGame/.vscode/launch.json b/TextBasedGame/.vscode/launch.json new file mode 100644 index 00000000..e28137c5 --- /dev/null +++ b/TextBasedGame/.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/TextBasedGame.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/TextBasedGame/.vscode/tasks.json b/TextBasedGame/.vscode/tasks.json new file mode 100644 index 00000000..7c08f701 --- /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..921125ea --- /dev/null +++ b/TextBasedGame/Program.cs @@ -0,0 +1,197 @@ +using System; + +namespace TextBasedGame +{ + class Program + { + public static void Main(string[] args) + { + int complete = 0; + bool alive = true; + while ( alive == true) + { + + + + Console.WriteLine("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); + Console.WriteLine("Welcome to the cavern of secrets!"); + Console.WriteLine("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); + + 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.Do you take it? [y/n]: "); + string ch1 = Console.ReadLine(); + + //Stick taken` + int stick = 0; + if (ch1 == "y") + { + System.Console.WriteLine("You have taken the stick!"); + System.Threading.Thread.Sleep(2000); + stick = 1; + } + + //Stick not takens + else if (ch1 == "n") + { + Console.WriteLine("You did not take the stick"); + stick = 0; + + } + + Console.WriteLine("As you proceed further into the cave, you see a small glowing object Do you approach the object? [y/n]"); + string ch2 = Console.ReadLine(); + + //Approach object + if (ch2 == "y") + { + System.Console.WriteLine("You approach the object"); + System.Threading.Thread.Sleep(2000); + System.Console.WriteLine("As you draw closer, you begin to make out the object as an eye!"); + System.Threading.Thread.Sleep(1000); + System.Console.WriteLine("The eye belongs to a giant spider! Do you try to fight it? [Y/N]"); + + } + string ch3 = Console.ReadLine(); + //Fight spider + if (ch3 == "Y") + { + //With stick + if (stick == 1) + { + System.Console.WriteLine("You only have a stick to fight with! You quickly jab the spider in it's eye and gain an advantage"); + System.Threading.Thread.Sleep(2000); + System.Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + System.Console.WriteLine(" Fighting... "); + System.Console.WriteLine(" YOU MUST HIT ABOVE A 5 TO KILL THE SPIDER "); + System.Console.WriteLine("IF THE SPIDER HITS HIGHER THAN YOU, YOU WILL DIE"); + System.Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + System.Threading.Thread.Sleep(2000); + Random rnd = new Random(); + int fdmg1 = rnd.Next(3, 10); + int edmg1 = rnd.Next(1, 5); + System.Console.WriteLine("you hit a " + fdmg1); + System.Console.WriteLine("the spider hits a " + edmg1); + System.Threading.Thread.Sleep(1000); + if (edmg1 > fdmg1) + { + System.Console.WriteLine("The spider has dealt more damage than you!"); + complete = 0; + //return complete; + } + else if (fdmg1 < 5) + { + System.Console.WriteLine("You didn't do enough damage to kill the spider, but you manage to escape"); + complete = 1; + //return complete; + } + else + { + System.Console.WriteLine("You killed the spider!"); + complete = 1; + //return complete; + } + } + //Without stick + else + { + System.Console.WriteLine("You don't have anything to fight with!"); + System.Threading.Thread.Sleep(2000); + System.Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + System.Console.WriteLine(" Fighting... "); + System.Console.WriteLine(" YOU MUST HIT ABOVE A 5 TO KILL THE SPIDER "); + System.Console.WriteLine("IF THE SPIDER HITS HIGHER THAN YOU, YOU WILL DIE"); + System.Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + System.Threading.Thread.Sleep(2000); + Random rnd = new Random(); + int fdmg2 = rnd.Next(1, 8); + int edmg2 = rnd.Next(1, 5); + System.Console.WriteLine("you hit a " + fdmg2); + System.Console.WriteLine("the spider hits a " + edmg2); + System.Threading.Thread.Sleep(2000); + if (edmg2 > fdmg2) + { + System.Console.WriteLine("The spider has dealt more damage than you!"); + complete = 0; + //return complete; + } + else if (fdmg2 < 5) + { + System.Console.WriteLine("You didn't do enough damage to kill the spider, but you manage to escape"); + complete = 1; + //return complete; + } + else + { + System.Console.WriteLine("You killed the spider!"); + complete = 1; + //return complete; + } + } + } + //Do Not Fight Spider + else if (ch3 == "N") + { + System.Console.WriteLine("You choose not to fight the spider."); + System.Threading.Thread.Sleep(1000); + System.Console.WriteLine("As you turn away, it ambushes you and impales you with it's fangs!!!"); + complete = 0; + //return complete + } + + //Do not approach object + else if (ch2 == "n") + { + System.Console.WriteLine("You turn away from the glowing object, and attempt to leave the cave..."); + System.Threading.Thread.Sleep(1000); + System.Console.WriteLine("But something won't let you...."); + System.Threading.Thread.Sleep(2000); + complete = 0; + //return complete + + } + if (complete == 1) + { Console.WriteLine("You managed to escape the cavern alive! Would you like to play again? [y/n]: "); + string choice = Console.ReadLine(); + if (choice == "y") + { + alive = true; + } + else if (choice == "n") + { + alive = false; + } + } + else + { + Console.WriteLine("You have died! Would you like to play again? [y/n]: "); + string choice2 = Console.ReadLine(); + if (choice2 == "y") + { + alive = true; + } + else + { + alive = false; + } + + } + + } + + + + + + + } + + + + + + + } + + +} + 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 c7f19cbcca517f9c5089b0a18f6c51e127a90d64 Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Wed, 16 Jan 2019 18:28:58 -0600 Subject: [PATCH 04/19] PigLatin --- PigLatin/PigLatin.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index 702647dd..bf0dc925 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -6,7 +6,14 @@ class Program { public static void Main() { - // your code goes here + string alphabet = "abcdefghijklmnopqrstuvwxyz"; + string firstThird = alphabet.Substring(0, 8); + string secondThird = alphabet.Substring(8, 8); + string thirdThird = alphabet.Substring(17); + + Console.WriteLine("First Third: " + firstThird); + Console.WriteLine("Second Third: " + secondThird); + Console.WriteLine("Third Third: " + thirdThird); // leave this command at the end so your program does not close automatically Console.ReadLine(); From c5eb4f4b2e83440cf41d1607e9b27e97e0c58777 Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Mon, 21 Jan 2019 18:16:06 -0600 Subject: [PATCH 05/19] PigLatin --- PigLatin/PigLatin.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index bf0dc925..27cf034c 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -6,14 +6,14 @@ class Program { public static void Main() { - string alphabet = "abcdefghijklmnopqrstuvwxyz"; - string firstThird = alphabet.Substring(0, 8); - string secondThird = alphabet.Substring(8, 8); - string thirdThird = alphabet.Substring(17); + + + System.Console.WriteLine("Translate word: "); + string engWord = Console.ReadLine(); + string PigLatin = TranslateWord(engWord); + System.Console.WriteLine(PigLatin); - Console.WriteLine("First Third: " + firstThird); - Console.WriteLine("Second Third: " + secondThird); - Console.WriteLine("Third Third: " + thirdThird); + // leave this command at the end so your program does not close automatically Console.ReadLine(); @@ -21,8 +21,10 @@ public static void Main() public static string TranslateWord(string word) { + string firstLetter = word.Substring(0,1); + string restWord = word.Substring(1); // your code goes here - return word; + return restWord + firstLetter + "ay"; } } } From cd84212f4a978d989d0205041363dece3873cd00 Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Mon, 28 Jan 2019 19:16:41 -0600 Subject: [PATCH 06/19] PigLatin --- PigLatin/PigLatin.cs | 17 ++++++++++++----- Sort/Program.cs | 12 ++++++++++++ Sort/Sort.csproj | 8 ++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 Sort/Program.cs create mode 100644 Sort/Sort.csproj diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index 27cf034c..8aa7728f 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -6,25 +6,32 @@ class Program { public static void Main() { - - + + System.Console.WriteLine("Translate word: "); string engWord = Console.ReadLine(); string PigLatin = TranslateWord(engWord); System.Console.WriteLine(PigLatin); - + // 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); // your code goes here return restWord + firstLetter + "ay"; + + char[] firstVowelIndex = { 'A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u' }; + string firstPart = word.Substring(0, firstVowelIndex); + string secondPart = word.Substring(firstVowelIndex); + + return secondPart + firstPart + "ay"; } } } diff --git a/Sort/Program.cs b/Sort/Program.cs new file mode 100644 index 00000000..73f1f40a --- /dev/null +++ b/Sort/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace Sort +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} 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 ff349a8128c6c3961a973fb650384902057b3a96 Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Mon, 28 Jan 2019 23:38:06 -0600 Subject: [PATCH 07/19] updated PigLatin branch --- PigLatin/PigLatin.cs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index 8aa7728f..1578f2de 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -7,7 +7,6 @@ class Program public static void Main() { - System.Console.WriteLine("Translate word: "); string engWord = Console.ReadLine(); string PigLatin = TranslateWord(engWord); @@ -15,6 +14,11 @@ public static void Main() + + + + + // leave this command at the end so your program does not close automatically Console.ReadLine(); } @@ -22,16 +26,24 @@ public static void Main() public static string TranslateWord(string word) { - string firstLetter = word.Substring(0, 1); - string restWord = word.Substring(1); - // your code goes here - return restWord + firstLetter + "ay"; - char[] firstVowelIndex = { 'A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u' }; - string firstPart = word.Substring(0, firstVowelIndex); - string secondPart = word.Substring(firstVowelIndex); + int firstVowelIndex = word.IndexOfAny(new char[] { 'A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u' }); + if (firstVowelIndex == 0) + { + return word + "yay"; + } + else if (firstVowelIndex != 0) + { + string firstLetter = word.Substring(0, 1); + string restWord = word.Substring(1); + // your code goes here + return restWord + firstLetter + "ay"; + } + + return word; - return secondPart + firstPart + "ay"; } } } + + From 1595348162a7da577efb411f259c6227ebc6def5 Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Tue, 29 Jan 2019 16:11:30 -0600 Subject: [PATCH 08/19] PigLatin --- PigLatin/PigLatin.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index 1578f2de..69a1a992 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -2,11 +2,11 @@ namespace PigLatin { - class Program + public class Program { public static void Main() { - + Console.WriteLine("fjdskjf"); System.Console.WriteLine("Translate word: "); string engWord = Console.ReadLine(); string PigLatin = TranslateWord(engWord); From 164c58369c2843eb32c122a8a3f46bc7eee6a7b2 Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Thu, 31 Jan 2019 17:31:28 -0600 Subject: [PATCH 09/19] Removed CW --- PigLatin/PigLatin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index 69a1a992..7df85f7c 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -6,7 +6,7 @@ public class Program { public static void Main() { - Console.WriteLine("fjdskjf"); + System.Console.WriteLine("Translate word: "); string engWord = Console.ReadLine(); string PigLatin = TranslateWord(engWord); From 20abb05fab978aa34d669a587472b3764b4edbec Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Thu, 31 Jan 2019 17:41:13 -0600 Subject: [PATCH 10/19] fixed PigLatin --- PigLatin/.vscode/launch.json | 28 +++++++++++++++++++++++ PigLatin/.vscode/tasks.json | 15 +++++++++++++ PigLatin/PigLatin.cs | 43 ++++++++++++++++++++++++------------ 3 files changed, 72 insertions(+), 14 deletions(-) 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..dbee6e56 --- /dev/null +++ b/PigLatin/.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/PigLatin.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/PigLatin/.vscode/tasks.json b/PigLatin/.vscode/tasks.json new file mode 100644 index 00000000..a705ed07 --- /dev/null +++ b/PigLatin/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/PigLatin.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index 10961fd7..46fa77c3 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -2,31 +2,46 @@ namespace PigLatin { - class Program + public class Program { public static void Main() { - // your code goes here - string alphabet = "abcdefghijklmnopqrstuvwxyz"; - string firstThird = alphabet.Substring(0, 8); - string secondThird = alphabet.Substring(8, 8); - string thirdThird = alphabet.Substring(17); - Console.WriteLine("First Third: " + firstThird); - Console.WriteLine("Second Third: " + secondThird); - Console.WriteLine("Third Third: " + thirdThird); + System.Console.WriteLine("Translate word: "); + string engWord = Console.ReadLine(); + string PigLatin = TranslateWord(engWord); + System.Console.WriteLine(PigLatin); + + + + + + - - // leave this command at the end so your program does not close automatically Console.ReadLine(); } - + public static string TranslateWord(string word) { - // your code goes here + + + int firstVowelIndex = word.IndexOfAny(new char[] { 'A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u' }); + if (firstVowelIndex == 0) + { + return word + "yay"; + } + else if (firstVowelIndex != 0) + { + string firstLetter = word.Substring(0, 1); + string restWord = word.Substring(1); + // your code goes here + return restWord + firstLetter + "ay"; + } + return word; + } } -} +} \ No newline at end of file From f3b426ab9066a9ab852f81f63971f863f970bc27 Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Thu, 31 Jan 2019 18:10:03 -0600 Subject: [PATCH 11/19] test --- test.html | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 test.html diff --git a/test.html b/test.html new file mode 100644 index 00000000..1df67406 --- /dev/null +++ b/test.html @@ -0,0 +1,10 @@ + + + + + + + Hello world + + + From 4cf2fa3a6eb080841b4ed38f3ce1b084a8a49b98 Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Wed, 6 Feb 2019 21:48:50 -0600 Subject: [PATCH 12/19] Mastermind --- Mastermind/.vscode/launch.json | 28 +++++++++++++++++++++++++ Mastermind/.vscode/tasks.json | 15 ++++++++++++++ Mastermind/Mastermind.cs | 38 +++++++++++++++++++--------------- 3 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 Mastermind/.vscode/launch.json create mode 100644 Mastermind/.vscode/tasks.json diff --git a/Mastermind/.vscode/launch.json b/Mastermind/.vscode/launch.json new file mode 100644 index 00000000..60c9449e --- /dev/null +++ b/Mastermind/.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/Mastermind.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/Mastermind/.vscode/tasks.json b/Mastermind/.vscode/tasks.json new file mode 100644 index 00000000..ccfc68f7 --- /dev/null +++ b/Mastermind/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/Mastermind.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Mastermind/Mastermind.cs b/Mastermind/Mastermind.cs index 365fb84c..c5cc64aa 100644 --- a/Mastermind/Mastermind.cs +++ b/Mastermind/Mastermind.cs @@ -6,23 +6,25 @@ class Program { // possible letters in code public static char[] letters = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }; - + // size of code public static int codeSize = 4; - + // number of allowed attempts to crack the code public static int allowedAttempts = 10; - + // number of tried guesses public static int numTry = 0; - + // test solution - public static char[] solution = new char[] {'a', 'b', 'c', 'd'}; - + public static char[] solution = new char[] { 'a', 'b', 'c', 'd' }; + + + // game board public static string[][] board = new string[allowedAttempts][]; - - + + public static void Main() { char[] guess = new char[4]; @@ -35,25 +37,26 @@ public static void Main() // leave this command at the end so your program does not close automatically Console.ReadLine(); } - + public static bool CheckSolution(char[] guess) { // Your code here + return false; } - + public static string GenerateHint(char[] guess) { // Your code here return " "; } - + public static void InsertCode(char[] guess) { // Your code here } - + public static void CreateBoard() { for (var i = 0; i < allowedAttempts; i++) @@ -65,19 +68,20 @@ public static void CreateBoard() } } } - + public static void DrawBoard() { for (var i = 0; i < board.Length; i++) { Console.WriteLine("|" + String.Join("|", board[i])); } - + } - - public static void GenerateRandomCode() { + + public static void GenerateRandomCode() + { Random rnd = new Random(); - for(var i = 0; i < codeSize; i++) + for (var i = 0; i < codeSize; i++) { solution[i] = letters[rnd.Next(0, letters.Length)]; } From 0acae5c49dcc5cafad54c67fb5237535f7cc8ee9 Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Thu, 14 Feb 2019 20:46:44 -0600 Subject: [PATCH 13/19] Undid changes --- Mastermind/Mastermind.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Mastermind/Mastermind.cs b/Mastermind/Mastermind.cs index c5cc64aa..46c6f96e 100644 --- a/Mastermind/Mastermind.cs +++ b/Mastermind/Mastermind.cs @@ -41,6 +41,10 @@ public static void Main() public static bool CheckSolution(char[] guess) { // Your code here + for (int i = 10; i > 0; i--) + { + + } return false; From c57d990c534feadd3fc457bab01e3f6bc0af836a Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Sat, 16 Feb 2019 13:41:40 -0600 Subject: [PATCH 14/19] Started assignment --- TowersOfHanoi/.vscode/launch.json | 28 +++++++++++++++++++++ TowersOfHanoi/.vscode/tasks.json | 15 +++++++++++ TowersOfHanoi/TowersOfHanoi.cs | 41 +++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 TowersOfHanoi/.vscode/launch.json create mode 100644 TowersOfHanoi/.vscode/tasks.json diff --git a/TowersOfHanoi/.vscode/launch.json b/TowersOfHanoi/.vscode/launch.json new file mode 100644 index 00000000..4ceac24d --- /dev/null +++ b/TowersOfHanoi/.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/TowersOfHanoi.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/TowersOfHanoi/.vscode/tasks.json b/TowersOfHanoi/.vscode/tasks.json new file mode 100644 index 00000000..bca810e7 --- /dev/null +++ b/TowersOfHanoi/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/TowersOfHanoi.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/TowersOfHanoi/TowersOfHanoi.cs b/TowersOfHanoi/TowersOfHanoi.cs index 10475b4a..41c1c952 100644 --- a/TowersOfHanoi/TowersOfHanoi.cs +++ b/TowersOfHanoi/TowersOfHanoi.cs @@ -1,12 +1,53 @@ using System; + + namespace TowersOfHanoi { class Program { static void Main(string[] args) { + Dictionary = new Dictionary(); + names.Add("Tower", "A"); + names.Add("Tower", "B"); + names.Add("Tower", "C"); + categories.Add("towers", new string[] { "A", "B", "C" }); + string towers1 = new towers1("A"); + string towers2 = new towers2("B"); + string towers3 = new towers3("C"); + Stack myStack = new Stack(); Console.WriteLine("Hello World!"); } } + class Block + { + public int Weight { get; private set; } + public Block(int Weight) + { + this.Weight = Weight; + } + } + + class Tower + { + public string Towers { get; set; } + public Tower(string name) + { + this.Name = name; + } + } + + class Game + { + foreach (KeyValuePair kv in names) + { + Console.WriteLine(kv.Key+" "+kv.Value); + } + + public MovePiece(string popOff, string pushOn) + { + + } +} } From ff2411f1fd4eaa1b92c7b886cb2f5a3360fe2619 Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Sat, 16 Feb 2019 17:00:07 -0600 Subject: [PATCH 15/19] Added code --- Mastermind/MasterMindTutoring | 109 +++++++++++++++++++++++++ Mastermind/MasterMindTutoring.cs | 131 ++++++++++++++++++++++++++++++ Mastermind/Mastermind.cs | 135 ++++++++++++++++++------------- 3 files changed, 320 insertions(+), 55 deletions(-) create mode 100644 Mastermind/MasterMindTutoring create mode 100644 Mastermind/MasterMindTutoring.cs diff --git a/Mastermind/MasterMindTutoring b/Mastermind/MasterMindTutoring new file mode 100644 index 00000000..e9f5a888 --- /dev/null +++ b/Mastermind/MasterMindTutoring @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; + +namespace Mastermind { + class Program { + + class Ball { + public string Letter { get; private set; } + + public Ball (string letter) { + this.Letter = letter; + } + } + + class Row { + public Ball[] balls = new Ball[4]; + + public Row (Ball[] balls) { + this.balls = balls; + } + + public string Balls { + get { + foreach (var ball in this.balls) { + Console.Write (ball.Letter); + } + return ""; + } + } + + class Game { + private List rows = new List (); + private string[] answer = new string[4]; + + public Game (string[] answer) { + this.answer = answer; + } + + private string Score (Row row) { + string[] answerClone = (string[]) this.answer.Clone (); + // red is correct letter and correct position + // white is correct letters minus red + // this.answer => ["a", "b", "c", "d"] + // row.balls => [{ Letter: "c" }, { Letter: "b" }, { Letter: "d" }, { Letter: "a" }] + int red = 0; + for (int i = 0; i < 4; i++) { + if (answerClone[i] == row.balls[i].Letter) { + red++; + } + } + + int white = 0; + for (int i = 0; i < 4; i++) { + int foundIndex = Array.IndexOf (answerClone, row.balls[i].Letter); + if (foundIndex > -1) { + white++; + answerClone[foundIndex] = null; + } + } + return " {red} - {white - red}"; + } + + public void AddRow (Row row) { + this.rows.Add (row); + } + + public string Rows + { + get { + foreach (var row in this.rows) + { + Console.Write (row.Balls); + Console.WriteLine (Score (row)); + } + return ""; + } + + } + + + + + + + + + + + + } + public static void Main (string[] args) { + Game game = new Game (new string[] { "a", "b", "c", "d" }); + for (int turns = 10; turns > 0; turns--) { + Console.WriteLine("You have {turns} tries left"); + Console.WriteLine ("Choose four letters: "); + string letters = Console.ReadLine (); + Ball[] balls = new Ball[4]; + for (int i = 0; i < 4; i++) { + balls[i] = new Ball (letters[i].ToString()); + } + Row row = new Row (balls); + game.AddRow (row); + Console.WriteLine (game.Rows); + } + Console.WriteLine ("Out Of Turns"); + } +} + + diff --git a/Mastermind/MasterMindTutoring.cs b/Mastermind/MasterMindTutoring.cs new file mode 100644 index 00000000..723e4567 --- /dev/null +++ b/Mastermind/MasterMindTutoring.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; + +namespace Mastermind +{ + class Program + { + + class Ball + { + public string Letter { get; private set; } + + public Ball(string letter) + { + this.Letter = letter; + } + } + + class Row + { + public Ball[] balls = new Ball[4]; + + public Row(Ball[] balls) + { + this.balls = balls; + } + + public string Balls + { + get + { + foreach (var ball in this.balls) + { + Console.Write(ball.Letter); + } + return ""; + } + } + + class Game + { + private List rows = new List(); + private string[] answer = new string[4]; + + public Game(string[] answer) + { + this.answer = answer; + } + + private string Score(Row row) + { + string[] answerClone = (string[])this.answer.Clone(); + // red is correct letter and correct position + // white is correct letters minus red + // this.answer => ["a", "b", "c", "d"] + // row.balls => [{ Letter: "c" }, { Letter: "b" }, { Letter: "d" }, { Letter: "a" }] + int red = 0; + for (int i = 0; i < 4; i++) + { + if (answerClone[i] == row.balls[i].Letter) + { + red++; + } + } + + int white = 0; + for (int i = 0; i < 4; i++) + { + int foundIndex = Array.IndexOf(answerClone, row.balls[i].Letter); + if (foundIndex > -1) + { + white++; + answerClone[foundIndex] = null; + } + } + return " {red} - {white - red}"; + } + + public void AddRow(Row row) + { + this.rows.Add(row); + } + + public string Rows + { + get + { + foreach (var row in this.rows) + { + Console.Write(row.Balls); + Console.WriteLine(Score(row)); + } + return ""; + } + + } + + + + + + + + + + + + } + public static void Main(string[] args) + { + Game game = new Game(new string[] { "a", "b", "c", "d" }); + for (int turns = 10; turns > 0; turns--) + { + Console.WriteLine("You have {turns} tries left"); + Console.WriteLine("Choose four letters: "); + string letters = Console.ReadLine(); + Ball[] balls = new Ball[4]; + for (int i = 0; i < 4; i++) + { + balls[i] = new Ball(letters[i].ToString()); + } + Row row = new Row(balls); + game.AddRow(row); + Console.WriteLine(game.Rows); + } + Console.WriteLine("Out Of Turns"); + } + } + } +} + diff --git a/Mastermind/Mastermind.cs b/Mastermind/Mastermind.cs index 46c6f96e..a5df5d09 100644 --- a/Mastermind/Mastermind.cs +++ b/Mastermind/Mastermind.cs @@ -1,94 +1,119 @@ using System; +using System.Collections.Generic; namespace Mastermind { - class Program + class Ball { - // possible letters in code - public static char[] letters = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }; - - // size of code - public static int codeSize = 4; - - // number of allowed attempts to crack the code - public static int allowedAttempts = 10; - - // number of tried guesses - public static int numTry = 0; - - // test solution - public static char[] solution = new char[] { 'a', 'b', 'c', 'd' }; + public string Letter { get; private set; } - - - // game board - public static string[][] board = new string[allowedAttempts][]; - - - public static void Main() + public Ball(string letter) { - char[] guess = new char[4]; + this.Letter = letter; + } + } - CreateBoard(); - DrawBoard(); - Console.WriteLine("Enter Guess:"); - guess = Console.ReadLine().ToCharArray(); + class Row + { + public Ball[] balls = new Ball[4]; - // leave this command at the end so your program does not close automatically - Console.ReadLine(); + public Row(Ball[] balls) + { + this.balls = balls; } - public static bool CheckSolution(char[] guess) + public string Balls { - // Your code here - for (int i = 10; i > 0; i--) + get { - + foreach (var ball in this.balls) + { + Console.Write(ball.Letter); + } + return ""; } - - - return false; } - public static string GenerateHint(char[] guess) - { - // Your code here - return " "; - } - public static void InsertCode(char[] guess) + } + class Game + { + public List rows = new List(); + private string[] answer = new string[4]; + + public Game(string[] answer) { - // Your code here + this.answer = answer; } - public static void CreateBoard() + private string Score(Row row) { - for (var i = 0; i < allowedAttempts; i++) + string[] answerClone = (string[])this.answer.Clone(); + // red is correct letter and correct position + // white is correct letters minus red + // this.answer => ["a", "b", "c", "d"] + // row.balls => [{ Letter: "c" }, { Letter: "b" }, { Letter: "d" }, { Letter: "a" }] + int red = 0; + for (int i = 0; i < 4; i++) { - board[i] = new string[codeSize + 1]; - for (var j = 0; j < codeSize + 1; j++) + if (answerClone[i] == row.balls[i].Letter) { - board[i][j] = " "; + red++; } } + int white = 0; + for (int i = 0; i < 4; i++) + { + int foundIndex = Array.IndexOf(answerClone, row.balls[i].Letter); + if (foundIndex > -1) + { + white++; + answerClone[foundIndex] = null; + } + } + return $" {red} - {white - red}"; + } + public void AddRow(Row row) + { + this.rows.Add(row); } - public static void DrawBoard() + public string Rows { - for (var i = 0; i < board.Length; i++) + get { - Console.WriteLine("|" + String.Join("|", board[i])); + foreach (var row in this.rows) + { + Console.Write(row.Balls); + Console.WriteLine(Score(row)); + } + return Rows; } + } - public static void GenerateRandomCode() + } + class Program + { + public static void Main(string[] args) { - Random rnd = new Random(); - for (var i = 0; i < codeSize; i++) + Game game = new Game(new string[] { "a", "b", "c", "d" }); + for (int turns = 10; turns > 0; turns--) { - solution[i] = letters[rnd.Next(0, letters.Length)]; + Console.WriteLine("You have {turns} tries left"); + Console.WriteLine("Choose four letters: "); + string letters = Console.ReadLine(); + Ball[] balls = new Ball[4]; + for (int i = 0; i < 4; i++) + { + balls[i] = new Ball(letters[i].ToString()); + } + Row row = new Row(balls); + game.rows.Add(row); + Console.WriteLine(game.Rows); } + Console.WriteLine("Out Of Turns"); } } } From 36d116fb4abdb81d44d2566d3566704db508c1d7 Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Sun, 17 Feb 2019 16:29:08 -0600 Subject: [PATCH 16/19] completed --- Mastermind/MasterMindTutoring | 109 ------------------------- Mastermind/MasterMindTutoring.cs | 131 ------------------------------- Mastermind/Mastermind.cs | 56 ++++++++++--- 3 files changed, 47 insertions(+), 249 deletions(-) delete mode 100644 Mastermind/MasterMindTutoring delete mode 100644 Mastermind/MasterMindTutoring.cs diff --git a/Mastermind/MasterMindTutoring b/Mastermind/MasterMindTutoring deleted file mode 100644 index e9f5a888..00000000 --- a/Mastermind/MasterMindTutoring +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Mastermind { - class Program { - - class Ball { - public string Letter { get; private set; } - - public Ball (string letter) { - this.Letter = letter; - } - } - - class Row { - public Ball[] balls = new Ball[4]; - - public Row (Ball[] balls) { - this.balls = balls; - } - - public string Balls { - get { - foreach (var ball in this.balls) { - Console.Write (ball.Letter); - } - return ""; - } - } - - class Game { - private List rows = new List (); - private string[] answer = new string[4]; - - public Game (string[] answer) { - this.answer = answer; - } - - private string Score (Row row) { - string[] answerClone = (string[]) this.answer.Clone (); - // red is correct letter and correct position - // white is correct letters minus red - // this.answer => ["a", "b", "c", "d"] - // row.balls => [{ Letter: "c" }, { Letter: "b" }, { Letter: "d" }, { Letter: "a" }] - int red = 0; - for (int i = 0; i < 4; i++) { - if (answerClone[i] == row.balls[i].Letter) { - red++; - } - } - - int white = 0; - for (int i = 0; i < 4; i++) { - int foundIndex = Array.IndexOf (answerClone, row.balls[i].Letter); - if (foundIndex > -1) { - white++; - answerClone[foundIndex] = null; - } - } - return " {red} - {white - red}"; - } - - public void AddRow (Row row) { - this.rows.Add (row); - } - - public string Rows - { - get { - foreach (var row in this.rows) - { - Console.Write (row.Balls); - Console.WriteLine (Score (row)); - } - return ""; - } - - } - - - - - - - - - - - - } - public static void Main (string[] args) { - Game game = new Game (new string[] { "a", "b", "c", "d" }); - for (int turns = 10; turns > 0; turns--) { - Console.WriteLine("You have {turns} tries left"); - Console.WriteLine ("Choose four letters: "); - string letters = Console.ReadLine (); - Ball[] balls = new Ball[4]; - for (int i = 0; i < 4; i++) { - balls[i] = new Ball (letters[i].ToString()); - } - Row row = new Row (balls); - game.AddRow (row); - Console.WriteLine (game.Rows); - } - Console.WriteLine ("Out Of Turns"); - } -} - - diff --git a/Mastermind/MasterMindTutoring.cs b/Mastermind/MasterMindTutoring.cs deleted file mode 100644 index 723e4567..00000000 --- a/Mastermind/MasterMindTutoring.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Mastermind -{ - class Program - { - - class Ball - { - public string Letter { get; private set; } - - public Ball(string letter) - { - this.Letter = letter; - } - } - - class Row - { - public Ball[] balls = new Ball[4]; - - public Row(Ball[] balls) - { - this.balls = balls; - } - - public string Balls - { - get - { - foreach (var ball in this.balls) - { - Console.Write(ball.Letter); - } - return ""; - } - } - - class Game - { - private List rows = new List(); - private string[] answer = new string[4]; - - public Game(string[] answer) - { - this.answer = answer; - } - - private string Score(Row row) - { - string[] answerClone = (string[])this.answer.Clone(); - // red is correct letter and correct position - // white is correct letters minus red - // this.answer => ["a", "b", "c", "d"] - // row.balls => [{ Letter: "c" }, { Letter: "b" }, { Letter: "d" }, { Letter: "a" }] - int red = 0; - for (int i = 0; i < 4; i++) - { - if (answerClone[i] == row.balls[i].Letter) - { - red++; - } - } - - int white = 0; - for (int i = 0; i < 4; i++) - { - int foundIndex = Array.IndexOf(answerClone, row.balls[i].Letter); - if (foundIndex > -1) - { - white++; - answerClone[foundIndex] = null; - } - } - return " {red} - {white - red}"; - } - - public void AddRow(Row row) - { - this.rows.Add(row); - } - - public string Rows - { - get - { - foreach (var row in this.rows) - { - Console.Write(row.Balls); - Console.WriteLine(Score(row)); - } - return ""; - } - - } - - - - - - - - - - - - } - public static void Main(string[] args) - { - Game game = new Game(new string[] { "a", "b", "c", "d" }); - for (int turns = 10; turns > 0; turns--) - { - Console.WriteLine("You have {turns} tries left"); - Console.WriteLine("Choose four letters: "); - string letters = Console.ReadLine(); - Ball[] balls = new Ball[4]; - for (int i = 0; i < 4; i++) - { - balls[i] = new Ball(letters[i].ToString()); - } - Row row = new Row(balls); - game.AddRow(row); - Console.WriteLine(game.Rows); - } - Console.WriteLine("Out Of Turns"); - } - } - } -} - diff --git a/Mastermind/Mastermind.cs b/Mastermind/Mastermind.cs index a5df5d09..453fb79f 100644 --- a/Mastermind/Mastermind.cs +++ b/Mastermind/Mastermind.cs @@ -40,13 +40,19 @@ class Game { public List rows = new List(); private string[] answer = new string[4]; + public string[] GenerateRandomCode = new string[4]; - public Game(string[] answer) + + public int tries; + + public Game(string[] answer, int tries) { this.answer = answer; + this.tries = tries; + } - private string Score(Row row) + public string Score(Row row) { string[] answerClone = (string[])this.answer.Clone(); // red is correct letter and correct position @@ -87,21 +93,34 @@ public string Rows Console.Write(row.Balls); Console.WriteLine(Score(row)); } - return Rows; + return ""; } - - } } class Program { + public static char[] letters = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }; + + public static void Main(string[] args) { - Game game = new Game(new string[] { "a", "b", "c", "d" }); + + bool win = false; + string[] GenerateRandomCode() + { + string[] solution = new string[4]; + Random rnd = new Random(); + for (var i = 0; i < 4; i++) + { + solution[i] = (letters[rnd.Next(0, letters.Length)]).ToString(); + } + return solution; + } + Game game = new Game(GenerateRandomCode(), 10); for (int turns = 10; turns > 0; turns--) { - Console.WriteLine("You have {turns} tries left"); + Console.WriteLine("You have {0} tries left", turns); Console.WriteLine("Choose four letters: "); string letters = Console.ReadLine(); Ball[] balls = new Ball[4]; @@ -110,10 +129,29 @@ public static void Main(string[] args) balls[i] = new Ball(letters[i].ToString()); } Row row = new Row(balls); - game.rows.Add(row); + game.AddRow(row); Console.WriteLine(game.Rows); + if (game.Score(row) == " 4 - 0") + { + System.Console.WriteLine("You win"); + win = true; + break; + } + + } + if (win == false) + { + Console.WriteLine("Out Of Turns"); } - Console.WriteLine("Out Of Turns"); + } + + + + + + + } } + From cf03090ad1a4841bab2cb58a94678ec264cc2c1c Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Mon, 18 Feb 2019 18:28:38 -0600 Subject: [PATCH 17/19] Added info --- TowersOfHanoi/TowersOfHanoi.cs | 124 +++++++++++++++++++++++++++------ 1 file changed, 104 insertions(+), 20 deletions(-) diff --git a/TowersOfHanoi/TowersOfHanoi.cs b/TowersOfHanoi/TowersOfHanoi.cs index 41c1c952..c1ba7305 100644 --- a/TowersOfHanoi/TowersOfHanoi.cs +++ b/TowersOfHanoi/TowersOfHanoi.cs @@ -1,5 +1,6 @@ using System; - +using System.Collections; +using System.Collections.Generic; namespace TowersOfHanoi @@ -8,46 +9,129 @@ class Program { static void Main(string[] args) { - Dictionary = new Dictionary(); - names.Add("Tower", "A"); - names.Add("Tower", "B"); - names.Add("Tower", "C"); - categories.Add("towers", new string[] { "A", "B", "C" }); - string towers1 = new towers1("A"); - string towers2 = new towers2("B"); - string towers3 = new towers3("C"); - Stack myStack = new Stack(); + + Game game = new Game(); + game.PrintBoard(); + game.AskMove(); + game.PrintBoard(); Console.WriteLine("Hello World!"); } } class Block { public int Weight { get; private set; } - public Block(int Weight) + public Block(int weight) { - this.Weight = Weight; + this.Weight = weight; } + } class Tower { public string Towers { get; set; } - public Tower(string name) + public Stack blocks = new Stack(); + public Tower(Stack block) { - this.Name = name; + this.blocks = block; } + } class Game { - foreach (KeyValuePair kv in names) - { - Console.WriteLine(kv.Key+" "+kv.Value); + Dictionary towers = new Dictionary(); + public Game() + { + Tower towerA = new Tower(new Stack()); + Tower towerB = new Tower(new Stack()); + Tower towerC = new Tower(new Stack()); + towers["A"] = towerA; + towers["B"] = towerB; + towers["C"] = towerC; + towerA.blocks.Push(new Block(4)); + towerA.blocks.Push(new Block(3)); + towerA.blocks.Push(new Block(2)); + towerA.blocks.Push(new Block(1)); } + public void PrintBoard() + { + foreach (KeyValuePair item in towers) + { + string blocks = ""; + foreach (Block block in item.Value.blocks) + { + blocks += block.Weight.ToString(); + } + System.Console.WriteLine(item.Key + "|" + blocks); + + } + + } + + public bool IsLegal(Tower from, Tower to) + { + Block popOff = from.blocks.Peek(); + Block pushOn = to.blocks.Peek(); + + if (pushOn == null) + { + return true; + } + else if (popOff.Weight < pushOn.Weight) + { + return true; + } + else + return false; + } + public void MovePiece(Tower from, Tower to) + { //2.Popoff the piece from the From Tower + //3.Push block on to To Tower + Block lastBlock = from.blocks.Pop(); + to.blocks.Push(lastBlock); + + + } + + public void AskMove() + { + System.Console.WriteLine("Which tower you do want to move from?"); + string fromTower = Console.ReadLine(); + System.Console.WriteLine("Which tower do you want to move to?"); + string toTower = Console.ReadLine(); + MovePiece(towers[fromTower], towers[toTower]); + } + + public bool CheckForWin() + { + if (towers["B"].blocks.Count == 4 || towers["C"].blocks.Count == 4) + { + System.Console.WriteLine("You Won!"); + return true; + } + else + return false; + + } + + + + + + + + + + + - public MovePiece(string popOff, string pushOn) - { } + + + } -} + + + From a40d62fc4c82399fc9641d5cc2f7e49dfa39d85a Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Mon, 18 Feb 2019 23:28:56 -0600 Subject: [PATCH 18/19] completed --- TowersOfHanoi/TowersOfHanoi.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/TowersOfHanoi/TowersOfHanoi.cs b/TowersOfHanoi/TowersOfHanoi.cs index c1ba7305..9ddb7a1a 100644 --- a/TowersOfHanoi/TowersOfHanoi.cs +++ b/TowersOfHanoi/TowersOfHanoi.cs @@ -9,12 +9,15 @@ class Program { static void Main(string[] args) { - Game game = new Game(); game.PrintBoard(); game.AskMove(); game.PrintBoard(); - Console.WriteLine("Hello World!"); + game.AskMove(); + + + + } } class Block @@ -40,6 +43,7 @@ public Tower(Stack block) class Game { + Block stack1 = new Block(4); Dictionary towers = new Dictionary(); public Game() { @@ -69,7 +73,7 @@ public void PrintBoard() } - public bool IsLegal(Tower from, Tower to) + public static bool IsLegal(Tower from, Tower to) { Block popOff = from.blocks.Peek(); Block pushOn = to.blocks.Peek(); From 4ca7090902c578463ce18cf2eef2e0188754393b Mon Sep 17 00:00:00 2001 From: Kristian Clark Date: Mon, 18 Feb 2019 23:41:50 -0600 Subject: [PATCH 19/19] complete --- Mastermind/Mastermind.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Mastermind/Mastermind.cs b/Mastermind/Mastermind.cs index 453fb79f..63718491 100644 --- a/Mastermind/Mastermind.cs +++ b/Mastermind/Mastermind.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; namespace Mastermind @@ -155,3 +156,9 @@ string[] GenerateRandomCode() } } + + + + + +