private void Next_Click(object sender, RoutedEventArgs e) { if (canNext) { answerBox.Text = String.Empty; if (iterator.HasNext()) { Question question = (Question)iterator.Next(); if (way == "pol->ang") { questionLabel.Content = question.question; question = new HintPolish(question, Database.GetPolishHint(question.ID)); } else { questionLabel.Content = question.answer; question = new HintEnglish(question, Database.GetEnglishHint(question.ID)); } questionLabel.ToolTip = (question as HintPolish).GetHint(); } else { ConcreteAggregate concreteAggregate = new ConcreteAggregate(); concreteAggregate.AddQuestions(test.questionChooseStrategy.GetQuestions("write", test.level.Nubmer)); iterator = concreteAggregate.CreateIterator(3); } canNext = false; } else { MessageBox.Show("You can't go further."); } checkBtn.Background = Brushes.LightGray; }
public StudyModeWindow(ref User user) { InitializeComponent(); command = new TestMode(user); command.Execute(); var tmp = random.Next(1, 4); IBuilder builder = new TestOpenBuilder( tmp == 1 ? new FactoryVeryEasy() : tmp == 2 ? new FactoryEasy() : tmp == 3 ? new FactoryNormal() : new FactoryHard() as AbstractFactory, "random"); user.MakeNewTest(builder); test = builder.PrintTest(); LvlLabel.Content = test.level.ToString(); ConcreteAggregate concreteAggregate = new ConcreteAggregate(); concreteAggregate.AddQuestions(test.questionChooseStrategy.GetQuestions("write", test.level.Nubmer)); iterator = concreteAggregate.CreateIterator(3); if (iterator.HasNext()) { Question question = (Question)iterator.Next(); if (way == "pol->ang") { questionLabel.Content = question.question; question = new HintPolish(question, Database.GetPolishHint(question.ID)); } else { questionLabel.Content = question.answer; question = new HintEnglish(question, Database.GetEnglishHint(question.ID)); } questionLabel.ToolTip = (question as HintPolish).GetHint(); } }
private void Run_Test(object sender, RoutedEventArgs e) { command.Execute(); OptionGrid.Visibility = Visibility.Collapsed; if (type == "Otwarty") { IBuilder builder = new TestOpenBuilder( skill == "Bardzo łatwy" ? new FactoryVeryEasy() : skill == "Łatwy" ? new FactoryEasy() : skill == "Średni" ? new FactoryNormal() : new FactoryHard() as AbstractFactory, strategy); user.MakeNewTest(builder); this.test = builder.PrintTest(); Open.Visibility = Visibility.Visible; ConcreteAggregate concreteAggregate = new ConcreteAggregate(); concreteAggregate.AddQuestions(test.questionChooseStrategy.GetQuestions("write", test.level.Nubmer)); iterator = concreteAggregate.CreateIterator(random.Next(3)); if (iterator.HasNext()) { Question question = iterator.Next(); if (way == "pol->ang") { question = new HintPolish(question, Database.GetPolishHint(question.ID)); PolishOpen.ToolTip = (question as HintPolish).GetHint(); } else { question.ChangeSolvingWay(); question = new HintEnglish(question, Database.GetEnglishHint(question.ID)); PolishOpen.ToolTip = (question as HintEnglish).GetHint(); } PolishOpen.Content = question.question; } } else if (type == "Zamkniety") { IBuilder builder = new TestCloseBuilder( skill == "Bardzo łatwy" ? new FactoryVeryEasy() : skill == "Łatwy" ? new FactoryEasy() : skill == "Średni" ? new FactoryNormal() : new FactoryHard() as AbstractFactory, strategy); user.MakeNewTest(builder); this.test = builder.PrintTest(); Test.Visibility = Visibility.Visible; ConcreteAggregate concreteAggregate = new ConcreteAggregate(); concreteAggregate.AddQuestions(test.questionChooseStrategy.GetQuestions("single", test.level.Nubmer)); iterator = concreteAggregate.CreateIterator(random.Next(3)); if (iterator.HasNext()) { Question question = iterator.Next(); if (way == "pol->ang") { question = new HintPolish(question, Database.GetPolishHint(question.ID)); Polish.ToolTip = (question as HintPolish).GetHint(); } else { question.ChangeSolvingWay(); question = new HintEnglish(question, Database.GetEnglishHint(question.ID)); Polish.ToolTip = (question as HintEnglish).GetHint(); } if (way == "pol->ang") { (iterator.Current() as CloseQuestion).GetWrongAnswers(false, test.level.Nubmer + 1, test.level.Nubmer); } else { (iterator.Current() as CloseQuestion).GetWrongAnswers(true, test.level.Nubmer + 1, test.level.Nubmer); } PopulateClosedAnswers((iterator.Current() as CloseQuestion).wrongAnswers); Polish.Content = question.question; } } }