Wrote the functions of VocabularyItem.cs
This commit is contained in:
parent
26c8e67c33
commit
bed0769995
2 changed files with 41 additions and 9 deletions
|
|
@ -88,7 +88,30 @@ public sealed class Trainer
|
|||
/// <returns>A <see cref="VocabularyItem"/> for each (valid) word</returns>
|
||||
private static VocabularyItem[] CreateVocabularyItems(string[][] wordsAndTranslations)
|
||||
{
|
||||
// TODO
|
||||
return [];
|
||||
VocabularyItem[] vocabularyItemsTemp = new VocabularyItem[wordsAndTranslations.Length];
|
||||
bool[] definedItems = new bool[wordsAndTranslations.Length];
|
||||
int usedItems = 0;
|
||||
for (var i = 0; i < wordsAndTranslations.Length; i++)
|
||||
{
|
||||
if (wordsAndTranslations[i].Length == 2)
|
||||
{
|
||||
usedItems++;
|
||||
definedItems[i] = true;
|
||||
vocabularyItemsTemp[i] = new VocabularyItem(wordsAndTranslations[i][WordIdx], wordsAndTranslations[i][TranslationIdx]);
|
||||
}
|
||||
}
|
||||
|
||||
VocabularyItem[] vocabularyItems = new VocabularyItem[usedItems];
|
||||
int j = 0;
|
||||
for (int i = 0; i < wordsAndTranslations.Length; i++)
|
||||
{
|
||||
if (definedItems[i])
|
||||
{
|
||||
vocabularyItems[j] = vocabularyItemsTemp[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
return vocabularyItems;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue