/// <summary> /// Builds the question, setting the possible answers and the good answer, depending on the difficulty. /// </summary> /// <param name="difficulty">The exercice difficulty.</param> /// <param name="random">The exercice random number generator.</param> public override void Build(ExerciceDifficulty difficulty, Random random) { decimal atmosphere = random.Next(0, 50) / 10.0M; decimal correctAnswer = atmosphere * AtmosphereToPascal; decimal randomRange = random.Next((int)correctAnswer / 10, (int)correctAnswer / 5); GenerateTitle(atmosphere); GenerateAnswersWithRange(correctAnswer, randomRange, 3, 6, random); }
/// <summary> /// Builds the question, setting the possible answers and the good answer, depending on the difficulty. /// </summary> /// <param name="difficulty">The exercice difficulty.</param> /// <param name="random">The exercice random number generator.</param> public override void Build(ExerciceDifficulty difficulty, Random random) { int speed = random.Next(10, 100); int mass = random.Next(500, 2000); decimal correctAnswer = 0.5M * mass * (int)Math.Pow(speed, 2); decimal randomRange = random.Next((int)correctAnswer / 10, (int)correctAnswer / 5); GenerateTitle(speed, speed * 3.6M, mass); GenerateAnswersWithRange(correctAnswer, randomRange, 3, 6, random); }
/// <summary> /// Builds the question, setting the possible answers and the good answer, depending on the difficulty. /// </summary> /// <param name="difficulty">The exercice difficulty.</param> /// <param name="random">The exercice random number generator.</param> public override void Build(ExerciceDifficulty difficulty, Random random) { SideA = random.Next(1, 20); SideB = random.Next(1, 20); decimal correctAnswer = (decimal)Math.Round(Math.Sqrt(Math.Pow((double)SideA, 2) + Math.Pow((double)SideB, 2)), 2); decimal randomRange = random.Next((int)correctAnswer / 10, (int)correctAnswer / 5); GenerateTitle(SideA, SideB); GenerateAnswersWithRange(correctAnswer, randomRange, 3, 6, random); }
/// <summary> /// Builds the question, setting the possible answers and the good answer, depending on the difficulty. /// </summary> /// <param name="difficulty">The exercice difficulty.</param> /// <param name="random">The exercice random number generator.</param> public override void Build(ExerciceDifficulty difficulty, Random random) { decimal startPrice = random.Next(50, 200); decimal percentage = random.Next(5, 30); percentage = (Type == QuestionPercentageType.Greater) ? percentage : -percentage; decimal correctAnswer = startPrice + (percentage / 100) * startPrice; decimal randomRange = random.Next((int)correctAnswer / 10, (int)correctAnswer / 5); GenerateTitle(startPrice, percentage); GenerateAnswersWithRange(correctAnswer, randomRange, 3, 6, random); }
/// <summary> /// Displays the current mask. /// </summary> /// <param name="difficulty"></param> /// <param name="tlp"></param> public void ShowMask(ExerciceDifficulty difficulty, TableLayoutPanel tlp) { tlp.Visible = true; tlp.Refresh(); switch (difficulty) { case ExerciceDifficulty.Easy: Thread.Sleep(ExercicePerception.timeEasy * 1000); // Wait 2 seconds, but freeze the thread (and UI) break; case ExerciceDifficulty.Hard: Thread.Sleep(ExercicePerception.timeHard * 1000); //System.Threading.Tasks.Task.Delay(4000); //Needs the Microsoft .NET framework 4.5 and higher. break; default: throw new NotImplementedException(); } tlp.Visible = false; }
/// <summary> /// Loads all difficulties. /// </summary> public void LoadDifficulties() { tableLayoutPanelDifficulties.ColumnCount = 0; ExerciceDifficulty[] difficulties = (ExerciceDifficulty[])Enum.GetValues(typeof(ExerciceDifficulty)); for (int i = 0; i < difficulties.Length; i++) { ExerciceDifficulty difficulty = difficulties[i]; Button button = new Button(); button.Text = ExerciceForm.GetLangString(difficulty.ToString()); button.Height = 40; button.Anchor = AnchorStyles.None; button.TabIndex = i; button.DialogResult = DialogResult.OK; button.Click += (sender, e) => { SelectedDifficulty = difficulty; }; tableLayoutPanelDifficulties.ColumnCount++; tableLayoutPanelDifficulties.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100.0F)); tableLayoutPanelDifficulties.Controls.Add(button, tableLayoutPanelDifficulties.ColumnCount - 1, 0); } }
/// <summary> /// Builds the question, setting the possible answers and the good answer, depending on the difficulty. /// </summary> /// <param name="difficulty">The exercice difficulty.</param> /// <param name="random">The exercice random number generator.</param> public override void Build(ExerciceDifficulty difficulty, Random random) { decimal maximum = 0; decimal minimum = decimal.MaxValue; Answers = new Polygon3D[random.Next(3, PossiblePolygons.Length + 1)]; for (int i = 0; i < Answers.Length; i++) { Polygon3D polygon = (Polygon3D)Activator.CreateInstance(PossiblePolygons[random.Next(0, PossiblePolygons.Length)], random); polygon.Name += string.Format(" {0}", i); decimal volume = (decimal)polygon.ComputeVolume(); switch (Type) { case QuestionVolumeType.Maximum: if (maximum < volume) { maximum = volume; Answer = i; } break; case QuestionVolumeType.Minimum: if (minimum > volume) { minimum = volume; Answer = i; } break; } Answers[i] = polygon; } GenerateTitle(); }
/// <summary> /// Builds the question, setting the possible answers and the good answer, depending on the difficulty. Needs to be implemented. /// </summary> /// <param name="difficulty">The exercice difficulty.</param> /// <param name="random">The exercice random number generator.</param> public abstract void Build(ExerciceDifficulty difficulty, Random random);