Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 65 additions & 8 deletions PigLatin/PigLatin.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,78 @@
using System;
using System.Collections.Generic;

namespace PigLatin
{
class Program
{
public static void Main()
public static void Main(string[] args)
{
// your code goes here
// run tests and print out if tests passed or not
if(tests()){
Console.WriteLine("Tests passed.");
} else {
Console.WriteLine("Tests failed.");
}

// leave this command at the end so your program does not close automatically
Console.ReadLine();
//your code to get user input and call TranslateWord method here

string word = "";


Console.WriteLine("Translate to Pig Latin, Enter a word {0}", word);
word = Console.ReadLine();
string pigLatin = ToPigLatin(word);
Console.WriteLine(pigLatin);

}
public static string TranslateWord(string word)

public static string ToPigLatin(string word)
{
// your code goes here
return word;
string vowels = "AEIOUaeio";
string PigWorded = "";


string firstLetter = word.Substring(0,1);

Console.WriteLine(firstLetter);

string restOfWord = word.Substring(1, word.Length -1);
Console.WriteLine(restOfWord);

int currentLetter = vowels.IndexOf(firstLetter);
Console.WriteLine(currentLetter);
if (currentLetter == -1)
{
PigWorded += (restOfWord + firstLetter + "ay");
}
else
{
PigWorded += (word + "yay");
}


return PigWorded;

}
/**
This method tests some examples against the 5 following rules,
and returns true if all tests pass, otherwise returns false.

rule 1: if it starts with a vowel add "yay" to the end
rule 2: move all letter before the first vowel to the end, then add "ay" to the end
rule 3: if it starts with a "y", treat the "y" as a consonant
rule 4: if it does not start with a "y", treat the "y" as a vowel
rule 5: if there are no vowels, add "ay" to the end (this is the same as rule 2)
*/
public static bool tests(){
return
ToPigLatin("elephant") == "elephantyay" &&
ToPigLatin("fox") == "oxfay" &&
ToPigLatin("choice") == "oicechay" &&
ToPigLatin("dye") == "yeday" &&
ToPigLatin("bystander") == "ystanderbay" &&
ToPigLatin("yellow") == "ellowyay" &&
ToPigLatin("tsktsk") == "tsktskay";
}
}
}
26 changes: 26 additions & 0 deletions Today/Today.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.IO;

namespace Today
{
class Today
{
static void Main(string[] args)
{
String file = @"/Users/jasonconnolly/Desktop/words.txt";
String[] lines = File.ReadAllLines(file);
//reading all lines and putting in an array

int lineNo =0;
foreach(String line in lines){
lineNo +=1;
Console.WriteLine(lineNo+"+line");
//reading each line and then writing to the console
}

String copy= @"/Users/jasonconnolly/Desktop/.txt";
File.WriteAllLines(copy, lines);
//creates new file and puts into new file
}
}
}
8 changes: 8 additions & 0 deletions Today/Today.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

</Project>
1 change: 1 addition & 0 deletions Today/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello Yousif
Loading