using System; using System.Collections.Generic; using System.Text; namespace CSharpUnitTesting { public class WordList { // Attributes private List _words; // Constructors public WordList() { _words = new List(); } // Properties // Methods public void AddWord(string word) { _words.Add(word); } public string GetWord(int index) { if (index < _words.Count) { return _words[index]; } return ""; } public bool ContainsWord(string word) { return _words.Contains(word); } public bool RemoveWord(string word) { return _words.Remove(word); } public bool RemoveWordAt(int index) { if (index < _words.Count) { _words.RemoveAt(index); return true; } return false; } public int GetWordIndex(string word) { for (int index = 0; index < _words.Count; index++) { if (_words[index] == word) return index; } return -1; } public bool GetLastWord(out string word) { if (_words.Count > 0) { word = _words[_words.Count-1]; return true; } word = ""; return false; } } }