Ejemplo n.º 1
0
        public override List <string> randomizeAnswers(Grid grid, WordTrans word, string lang)
        {
            int num = rand.Next(4);

            List <string> words = new List <string>();

            if (lang == "pol")
            {
                words.Add(word.wordPol.content);
            }
            else
            {
                words.Add(word.content);
            }
            string randomAns = null;

            for (int i = 0; i < 4; i++)
            {
                if (i != num)
                {
                    if (lang == "pol")
                    {
                        randomAns = facade.getRandomTransWord(word.lang).wordPol.content;
                    }
                    else
                    {
                        randomAns = facade.getRandomTransWord(word.lang).content;
                    }
                    if (!words.Contains(randomAns))
                    {
                        grid.Children.OfType <RadioButton>().ElementAt(i).Content = randomAns;
                        words.Add(randomAns);
                    }
                    else
                    {
                        i--;
                    }
                }
                else
                {
                    if (lang == "pol")
                    {
                        grid.Children.OfType <RadioButton>().ElementAt(i).Content = word.wordPol.content;
                    }
                    else
                    {
                        grid.Children.OfType <RadioButton>().ElementAt(i).Content = word.content;
                    }
                }
            }
            return(words);
        }
Ejemplo n.º 2
0
        public void Stud(Grid grid, DifficultyLevel difficultyLevel, string lang, List <string> previousAnswers)
        {
            this.previousAnswers = previousAnswers;
            bool AnsCorrect;

            this.grid = grid;
            string ans = difficultyLevel.getAns(grid);

            if (lang == "pol")
            {
                AnsCorrect = checkAns(ans, actualWord.wordPol.content);
            }
            else
            {
                AnsCorrect = checkAns(ans, actualWord.content);
            }

            if (AnsCorrect)
            {
                WordTrans tempactualWord = facade.getRandomTransWord(actualWord.lang);
                while (tempactualWord.content.Equals(actualWord.content))
                {
                    tempactualWord = facade.getRandomTransWord(actualWord.lang);
                }
                actualWord = tempactualWord;
                if (lang == "pol")
                {
                    grid.Children.OfType <Label>().FirstOrDefault().Content = actualWord.content;
                }
                else
                {
                    grid.Children.OfType <Label>().FirstOrDefault().Content = actualWord.wordPol.content;
                }
                answers = difficultyLevel.randomizeAnswers(grid, actualWord, lang);
                if (difficultyLevel.strategy.GetType() != typeof(Master) && grid.Children.OfType <RadioButton>().FirstOrDefault(r => (bool)r.IsChecked) != null)
                {
                    grid.Children.OfType <RadioButton>().FirstOrDefault(r => (bool)r.IsChecked).IsChecked = false;
                }
                else if (difficultyLevel.strategy.GetType() == typeof(Master))
                {
                    grid.Children.OfType <TextBox>().FirstOrDefault().Text = null;
                }
            }
        }
Ejemplo n.º 3
0
        public TrainingPage(string lvl, string lang, string type, string mode)
        {
            switch (type)
            {
            case "training":
                action = new Training();
                break;

            case "Test":
                action = new Test();
                break;
            }
            switch (lvl)
            {
            case "Łatwy":
                dificulty = new DifficultyLevel(new Easy());
                break;

            case "Normalny":
                dificulty = new DifficultyLevel(new Normal());
                break;

            case "Trudny":
                dificulty = new DifficultyLevel(new Hard());
                break;

            case "Ekspert":
                dificulty = new DifficultyLevel(new Expert());
                break;

            case "Mistrz":
                dificulty = new DifficultyLevel(new Master());
                break;
            }

            this.mode = mode;
            InitializeComponent();
            if (type == "Test")
            {
                wrongAnswerLabel.Content = "pytanie 1/10";
            }
            if (action.GetType() == typeof(Training))
            {
                previousQuestion.Visibility = Visibility.Hidden;
                TestButton.Margin           = new Thickness(0, 0, 0, 10);
            }
            else
            {
                previousQuestion.IsEnabled = false;
            }
            wordTrans = facade.getRandomTransWord(lang);
            dificulty.generateAns(radios);
            if (mode == "Polski->Obcy")
            {
                previousAnswers   = dificulty.randomizeAnswers(radios, wordTrans, lang);
                WordLabel.Content = wordTrans.wordPol.content;
                action.actualWord = wordTrans;
            }
            else
            {
                previousAnswers   = dificulty.randomizeAnswers(radios, wordTrans, "pol");
                WordLabel.Content = wordTrans.content;
                action.actualWord = wordTrans;
            }
        }
Ejemplo n.º 4
0
 public List <string> randomizeAnswers(Grid grid, WordTrans word, string lang)
 {
     return(strategy.randomizeAnswers(grid, word, lang));
 }
Ejemplo n.º 5
0
 public void addWord(WordTrans word)
 {
     aggregate.insertTrans(word);
 }
Ejemplo n.º 6
0
 public void insertTrans(WordTrans word)
 {
     transWords.Add(word);
 }
Ejemplo n.º 7
0
 public abstract List <string> randomizeAnswers(Grid grid, WordTrans word, string lang);
Ejemplo n.º 8
0
 public override List <string> randomizeAnswers(Grid grid, WordTrans word, string lang)
 {
     //throw new NotImplementedException();
     return(null);
 }