diff --git a/VocabularyTrainer/VocabularyItem.cs b/VocabularyTrainer/VocabularyItem.cs index 12ea2a9..adb8828 100644 --- a/VocabularyTrainer/VocabularyItem.cs +++ b/VocabularyTrainer/VocabularyItem.cs @@ -5,5 +5,63 @@ /// public sealed class VocabularyItem { - // TODO + private int _countCorrect; + private int _countAsked; + public readonly string NativeWord; + public readonly string Translation; + + VocabularyItem(string nativeWord, string translation) + { + NativeWord = nativeWord; + Translation = translation; + } + + /// + /// A translation attempt is checked for correctness. + /// + /// The user provided translation + /// True if the translation was correct; false otherwise + public bool TestTranslation(string translationAttempt) + { + _countAsked++; + if (Translation == translationAttempt) + { + _countCorrect++; + return true; + } + + return false; + } + + /// + /// The vocabulary item is compared to another. First the number of correct answers is compared. + /// If it is equal the native words are compared ordinal. + /// + /// The to compare with + /// 0 if equal; less than 0 if this item is smaller; greater than 0 otherwise + public int CompareTo(VocabularyItem other) + { + return -1; + } + + /// + /// Overrides the default string representation to display the word and translation statistics. + /// + /// A string containing the word, its translation and the training statistics + public override string ToString() + { + return string.Empty; + } + + /// + /// Compares two strings by ordinal value, ignoring case. + /// + /// First string + /// Second string + /// Less than 0 if a precedes b in the sorting order; greater than 0 if b precedes a; 0 otherwise + + private static int CompareStrings(string a, string b) + { + return -1; + } } \ No newline at end of file