diff --git a/HelloWorld/HelloWorld.cs b/HelloWorld/HelloWorld.cs index 8168c805..05429f85 100644 --- a/HelloWorld/HelloWorld.cs +++ b/HelloWorld/HelloWorld.cs @@ -1,12 +1,25 @@ using System; -namespace HelloWorld +public class Program { - class Program + public static void Main() { - static void Main(string[] args) - { - Console.WriteLine("Hello World!"); - } - } + string name = ""; + int age = 0; + int year = 0; + + + Console.WriteLine("Please enter your name: "); + name = Console.ReadLine(); + Console.WriteLine("Please enter your age: "); + age = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Please enter the year: "); + year = Convert.ToInt32(Console.ReadLine()); + + Console.WriteLine("Hello! My name is {0} and I am {1} years old I was born in {2}.", name, age, year-age); + } + + } + + diff --git a/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..63718491 100644 --- a/Mastermind/Mastermind.cs +++ b/Mastermind/Mastermind.cs @@ -1,86 +1,164 @@ using System; +using System.Collections; +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'}; - - // game board - public static string[][] board = new string[allowedAttempts][]; - - - public static void Main() + public string Letter { get; private set; } + + public Ball(string letter) { - char[] guess = new char[4]; + this.Letter = letter; + } + } + + class Row + { + public Ball[] balls = new Ball[4]; - CreateBoard(); - DrawBoard(); - Console.WriteLine("Enter Guess:"); - guess = Console.ReadLine().ToCharArray(); + public Row(Ball[] balls) + { + this.balls = balls; + } - // leave this command at the end so your program does not close automatically - Console.ReadLine(); + public string Balls + { + get + { + foreach (var ball in this.balls) + { + Console.Write(ball.Letter); + } + return ""; + } } - - public static bool CheckSolution(char[] guess) + + + } + class Game + { + public List rows = new List(); + private string[] answer = new string[4]; + public string[] GenerateRandomCode = new string[4]; + + + public int tries; + + public Game(string[] answer, int tries) { - // Your code here + this.answer = answer; + this.tries = tries; - return false; } - - public static string GenerateHint(char[] guess) + + public string Score(Row row) { - // Your code here - return " "; + 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 static void InsertCode(char[] guess) + public void AddRow(Row row) { - // Your code here + this.rows.Add(row); } - - public static void CreateBoard() + + public string Rows { - for (var i = 0; i < allowedAttempts; i++) + get { - board[i] = new string[codeSize + 1]; - for (var j = 0; j < codeSize + 1; j++) + foreach (var row in this.rows) { - board[i][j] = " "; + Console.Write(row.Balls); + Console.WriteLine(Score(row)); } + return ""; } } - - public static void DrawBoard() + + } + class Program + { + public static char[] letters = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }; + + + public static void Main(string[] args) { - for (var i = 0; i < board.Length; i++) + + bool win = false; + string[] GenerateRandomCode() { - Console.WriteLine("|" + String.Join("|", board[i])); + 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; } - - } - - public static void GenerateRandomCode() { - Random rnd = new Random(); - for(var i = 0; i < codeSize; i++) + Game game = new Game(GenerateRandomCode(), 10); + for (int turns = 10; turns > 0; turns--) + { + Console.WriteLine("You have {0} tries left", turns); + 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); + if (game.Score(row) == " 4 - 0") + { + System.Console.WriteLine("You win"); + win = true; + break; + } + + } + if (win == false) { - solution[i] = letters[rnd.Next(0, letters.Length)]; + Console.WriteLine("Out Of Turns"); } + } + + + + + + + } } + + + + + + + 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 702647dd..46fa77c3 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -2,20 +2,46 @@ namespace PigLatin { - class Program + public class Program { public static void Main() { - // your code goes here + + 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 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 + + + 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 + + +