Esempio n. 1
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;
                }
            }
        }
Esempio n. 2
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;
            }
        }