예제 #1
0
파일: Hard.cs 프로젝트: 35T4N0R/LearnWords
        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);
        }
예제 #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;
                }
            }
        }
예제 #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;
            }
        }
예제 #4
0
 public List <string> randomizeAnswers(Grid grid, WordTrans word, string lang)
 {
     return(strategy.randomizeAnswers(grid, word, lang));
 }
예제 #5
0
 public void addWord(WordTrans word)
 {
     aggregate.insertTrans(word);
 }
예제 #6
0
 public void insertTrans(WordTrans word)
 {
     transWords.Add(word);
 }
예제 #7
0
 public abstract List <string> randomizeAnswers(Grid grid, WordTrans word, string lang);
예제 #8
0
 public override List <string> randomizeAnswers(Grid grid, WordTrans word, string lang)
 {
     //throw new NotImplementedException();
     return(null);
 }