I'm writing a simple language translator which will present the English word and ask for the corresponding foreign word. So far the code will select a random word from an array, however i'm now trying to get it to select the corresponding foreign word from the list. Here's the code so far:
public class Words
{
public int spanishindex;
string[] EnglishWords = { "Yellow", "Yello", "Yelow", "Yllow", "ellow" };
string[] SpanishWords= { "giallo", "giall", "iallo", "gllo", "lo" };
public String GetRandomWord()
{
Random randomizer = new Random();
index = randomizer.Next(EnglishWords.Length);
string randomword = EnglishWords[randomizer.Next(index)];
spanishindex= index;
return randomword;
}
public String MatchSpanishWord()
{
string matchword = SpanishWords[spanishindex];
return matchword;
}
}
My thoughts were by passing in the index value oppose to a random value in the MatchSpanishWord method i would get the corresponding word (as the list is in order)
So if 'ellow' is selected the spanish equivalent should be 'lo'
Any help would be appreciated, thanks.