From 26c8e67c33f783a23faddb182bf316c6af7d3cc4 Mon Sep 17 00:00:00 2001 From: MarcUs7i <96580944+MarcUs7i@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:19:23 +0100 Subject: [PATCH] Declared the methods and copied the XMLDoc from the readme.adoc file to each method --- VocabularyTrainer/VocabularyItem.cs | 60 ++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) 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