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); } } + } 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..bc2d39a4 100644 --- a/PigLatin/PigLatin.cs +++ b/PigLatin/PigLatin.cs @@ -7,15 +7,34 @@ class Program public static void Main() { // your code goes here + System.Console.WriteLine("enter the phrase you want to translate:"); + string input = Console.ReadLine().ToLower(); + string output = ""; + char[] punctuation = new char[] { ',', '?', '"' }; - // leave this command at the end so your program does not close automatically - Console.ReadLine(); + string[] words = input.Split(' '); + foreach (var item in words) + { + output += TranslateWord(item) + " "; + } + Console.WriteLine(output); } - - 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; } } } 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 + + +