From 0efcbd071b1f9eab129606e1a400f3d6b2f7d1ab Mon Sep 17 00:00:00 2001 From: Sam Mangum-Bostick Date: Mon, 7 Jan 2019 20:52:04 -0600 Subject: [PATCH 1/3] Finished --- HelloWorld/HelloWorld.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/HelloWorld/HelloWorld.cs b/HelloWorld/HelloWorld.cs index d25a8c44..3a382d3c 100644 --- a/HelloWorld/HelloWorld.cs +++ b/HelloWorld/HelloWorld.cs @@ -12,4 +12,5 @@ static void Main(string[] args) Console.Write(yourName); } } + } From 0bbae61675e23fefb3e698161e2d74aadb9ca46d Mon Sep 17 00:00:00 2001 From: Sam Mangum-Bostick Date: Wed, 16 Jan 2019 18:24:18 -0600 Subject: [PATCH 2/3] Added code --- PigLatin/.vscode/launch.json | 28 ++++++++++++++++++++++++++++ PigLatin/.vscode/tasks.json | 15 +++++++++++++++ PigLatin/PigLatin.cs | 11 +++++++++++ Practice/Program.cs | 23 +++++++++++++++++++++++ Practice/practice.csproj | 8 ++++++++ 5 files changed, 85 insertions(+) create mode 100644 PigLatin/.vscode/launch.json create mode 100644 PigLatin/.vscode/tasks.json create mode 100644 Practice/Program.cs create mode 100644 Practice/practice.csproj 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..bf980347 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -7,7 +7,17 @@ class Program public static void Main() { // your code goes here + string firstWord = "simple "; + string secondWord = "word"; + string firstLetter = firstWord.Substring(0,1); + string restWord = firstWord.Substring(1,5); + + string secondFirstLetter = secondWord.Substring(0,1); + string secondRestWord = secondWord.Substring(1,3); + + Console.WriteLine(restWord + firstLetter + "ay"); + Console.WriteLine(secondRestWord + secondFirstLetter + "ay"); // leave this command at the end so your program does not close automatically Console.ReadLine(); } @@ -15,6 +25,7 @@ public static void Main() public static string TranslateWord(string word) { // your code goes here + return word; } } diff --git a/Practice/Program.cs b/Practice/Program.cs new file mode 100644 index 00000000..495fc09d --- /dev/null +++ b/Practice/Program.cs @@ -0,0 +1,23 @@ +using System; + +namespace practice +{ + class Program + { + static void Main(string[] args) + { + string firstWord = "simple "; + string secondWord = "word"; + + string firstLetter = firstWord.Substring(0,1); + string restWord = firstWord.Substring(1,5); + + string secondFirstLetter = secondWord.Substring(0,1); + string secondRestWord = secondWord.Substring(1,3); + + Console.WriteLine(restWord + firstLetter + "ay"); + Console.WriteLine(secondRestWord + secondFirstLetter + "ay"); + + } + } +} diff --git a/Practice/practice.csproj b/Practice/practice.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/Practice/practice.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + From c25f815ee79f61de22f70190bc7a55694982a669 Mon Sep 17 00:00:00 2001 From: Sam Mangum-Bostick Date: Mon, 21 Jan 2019 17:53:29 -0600 Subject: [PATCH 3/3] Finished --- PigLatin/PigLatin.cs | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs index bf980347..bc2d39a4 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -7,26 +7,34 @@ class Program public static void Main() { // your code goes here - string firstWord = "simple "; - string secondWord = "word"; + System.Console.WriteLine("enter the phrase you want to translate:"); + string input = Console.ReadLine().ToLower(); + string output = ""; + char[] punctuation = new char[] { ',', '?', '"' }; - string firstLetter = firstWord.Substring(0,1); - string restWord = firstWord.Substring(1,5); + string[] words = input.Split(' '); + foreach (var item in words) + { + output += TranslateWord(item) + " "; + } + Console.WriteLine(output); + } - string secondFirstLetter = secondWord.Substring(0,1); - string secondRestWord = secondWord.Substring(1,3); - Console.WriteLine(restWord + firstLetter + "ay"); - Console.WriteLine(secondRestWord + secondFirstLetter + "ay"); - // leave this command at the end so your program does not close automatically - Console.ReadLine(); - } - - public static string TranslateWord(string word) + public static string TranslateWord(string input) { // your code goes here - - return word; + char[] vowels = new char[] { 'a', 'e', 'i', 'o', 'u' }; + int firstLetterIndex = input.IndexOfAny(vowels); + string firstPart = input.Substring(0, firstLetterIndex); + string restWord = input.Substring(firstLetterIndex); + input = restWord + firstPart + "ay"; + + if (firstLetterIndex == 0) + { + input = restWord + "yay"; + } + return input; } } }