static void Main(string[] args) { Console.WriteLine("Please enter your poem:"); WordCounter dictionary = new WordCounter(100); string[] poem = Console.ReadLine().Split(" "); for (int i = 0; i < poem.Length; i++) { dictionary.AddWordToList(poem[i]); } for (int i = 0; i < dictionary.GetNextFreeeLocation(); i++) { Console.WriteLine(dictionary.GetList()[i].GetWord() + " - " + dictionary.GetList()[i].GetCount()); } Console.ReadLine(); }
static void Main(string[] args) { WordCounter dictionary = new WordCounter(100); string currentWord = ""; // I should read in line of text // process line of text, looking for individual words // for each word for WordCounter AddString // start with just a word at a time :-) while (currentWord != "STOP") { currentWord = Console.ReadLine(); if (currentWord != "STOP") { dictionary.AddString(currentWord); } } }
static void Main(string[] args) { WordCounter dictionary = new WordCounter(100); string currentWord = ""; Console.WriteLine("Enter you words, one per line, ending with STOP"); // start with just a word at a time :-) while (currentWord != "STOP") { currentWord = Console.ReadLine(); if (currentWord != "STOP") { dictionary.AddString(currentWord); } } // Now let's print it all out - by autocalling ToString Console.WriteLine(dictionary); Console.ReadLine(); }
static void Main(string[] args) { WordCounter dictionary = new WordCounter(100); string currentWord = ""; Console.WriteLine("Enter you words, one per line, ending with STOP"); while (currentWord != "STOP") { currentWord = Console.ReadLine(); if (currentWord != "STOP") { dictionary.AddString(currentWord); } } Console.WriteLine(dictionary); Console.ReadLine(); }