Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Test]
- public void TestExercise4()
- {
- Programmeren2Tests.Chapter12Test.TestExercise4(Exercise4);
- }
- public static int Exercise4()
- {
- int count = 0;
- foreach (string str in LoadAliceInWonderland())
- if (str == "queen")
- count++;
- return count;
- //throw new NotImplementedException();
- }
- //load the book (from file) and return it as a string array
- public static string[] LoadAliceInWonderland()
- {
- string aliceFile = Path.Combine(Environment.CurrentDirectory, "bestanden\\alice_in_wonderland.txt");
- string text = File.ReadAllText(aliceFile).ToLower();
- string[] words = removeUselessValues(text).Split();
- return words;
- }
- public static string removeUselessValues(string s)
- {
- string result = "";
- foreach (char c in s)
- result += (c.Equals('q') || c.Equals('u') || c.Equals('e') || c.Equals('n')) ? c : ' ';
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement