added funtionality for rdo buttons and addede the ChangeOperator Function

This commit is contained in:
EggMan20339 2024-02-01 10:08:18 -05:00
parent 6729fed857
commit 023b620256
2 changed files with 199 additions and 177 deletions

View File

@ -29,76 +29,93 @@
/// </summary>
private void InitializeComponent()
{
this.grpLevels = new System.Windows.Forms.GroupBox();
this.rdoLvl1 = new System.Windows.Forms.RadioButton();
this.grpOperations = new System.Windows.Forms.GroupBox();
this.rdoDivision = new System.Windows.Forms.RadioButton();
this.rdoMultiplication = new System.Windows.Forms.RadioButton();
this.rdoSubtraction = new System.Windows.Forms.RadioButton();
this.rdoAddition = new System.Windows.Forms.RadioButton();
this.pnlSummary = new System.Windows.Forms.Panel();
this.lblNumIncorrect = new System.Windows.Forms.Label();
this.lblNumCorrect = new System.Windows.Forms.Label();
this.lblDisIncorrect = new System.Windows.Forms.Label();
this.lblDisCorrect = new System.Windows.Forms.Label();
this.pnlCalc = new System.Windows.Forms.Panel();
this.lblImage = new System.Windows.Forms.Label();
this.btnReset = new System.Windows.Forms.Button();
this.btnClear = new System.Windows.Forms.Button();
this.btnShowCorrectAnswer = new System.Windows.Forms.Button();
this.btnChkAnswer = new System.Windows.Forms.Button();
this.lblMessage = new System.Windows.Forms.Label();
this.lblOperator = new System.Windows.Forms.Label();
this.lblDisEqual = new System.Windows.Forms.Label();
this.txtC = new System.Windows.Forms.TextBox();
this.txtB = new System.Windows.Forms.TextBox();
this.txtA = new System.Windows.Forms.TextBox();
this.rdoLvl2 = new System.Windows.Forms.RadioButton();
this.rdoAddition = new System.Windows.Forms.RadioButton();
this.rdoSubtraction = new System.Windows.Forms.RadioButton();
this.rdoMultiplication = new System.Windows.Forms.RadioButton();
this.rdoDivision = new System.Windows.Forms.RadioButton();
this.chkShowSummary = new System.Windows.Forms.CheckBox();
this.lblMessage = new System.Windows.Forms.Label();
this.btnChkAnswer = new System.Windows.Forms.Button();
this.btnShowCorrectAnswer = new System.Windows.Forms.Button();
this.btnClear = new System.Windows.Forms.Button();
this.btnReset = new System.Windows.Forms.Button();
this.lblDisCorrect = new System.Windows.Forms.Label();
this.lblDisIncorrect = new System.Windows.Forms.Label();
this.lblNumCorrect = new System.Windows.Forms.Label();
this.lblNumIncorrect = new System.Windows.Forms.Label();
this.lblImage = new System.Windows.Forms.Label();
this.btnExit = new System.Windows.Forms.Button();
this.btnPrint = new System.Windows.Forms.Button();
this.grpLevels.SuspendLayout();
this.grpOperations.SuspendLayout();
this.pnlSummary.SuspendLayout();
this.pnlCalc.SuspendLayout();
this.SuspendLayout();
//
// grpLevels
//
this.grpLevels.Controls.Add(this.rdoLvl2);
this.grpLevels.Controls.Add(this.rdoLvl1);
this.grpLevels.Location = new System.Drawing.Point(60, 225);
this.grpLevels.Name = "grpLevels";
this.grpLevels.Size = new System.Drawing.Size(211, 120);
this.grpLevels.TabIndex = 0;
this.grpLevels.TabStop = false;
this.grpLevels.Text = "Levels";
this.grpLevels.Enter += new System.EventHandler(this.groupBox1_Enter);
//
// rdoLvl1
//
this.rdoLvl1.Location = new System.Drawing.Point(28, 32);
this.rdoLvl1.Name = "rdoLvl1";
this.rdoLvl1.Size = new System.Drawing.Size(101, 18);
this.rdoLvl1.TabIndex = 0;
this.rdoLvl1.TabStop = true;
this.rdoLvl1.Text = "Level 1 (1-10)";
this.rdoLvl1.UseVisualStyleBackColor = true;
this.rdoLvl1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// grpOperations
//
this.grpOperations.Controls.Add(this.rdoDivision);
this.grpOperations.Controls.Add(this.rdoMultiplication);
this.grpOperations.Controls.Add(this.rdoSubtraction);
this.grpOperations.Controls.Add(this.rdoAddition);
this.grpOperations.Location = new System.Drawing.Point(287, 225);
this.grpOperations.Location = new System.Drawing.Point(208, 224);
this.grpOperations.Name = "grpOperations";
this.grpOperations.Size = new System.Drawing.Size(211, 120);
this.grpOperations.TabIndex = 1;
this.grpOperations.TabStop = false;
this.grpOperations.Text = "Operations";
//
// rdoDivision
//
this.rdoDivision.Location = new System.Drawing.Point(109, 62);
this.rdoDivision.Name = "rdoDivision";
this.rdoDivision.Size = new System.Drawing.Size(77, 23);
this.rdoDivision.TabIndex = 3;
this.rdoDivision.TabStop = true;
this.rdoDivision.Text = "Division";
this.rdoDivision.UseVisualStyleBackColor = true;
this.rdoDivision.CheckedChanged += new System.EventHandler(this.rdoDivision_CheckedChanged);
//
// rdoMultiplication
//
this.rdoMultiplication.Location = new System.Drawing.Point(109, 30);
this.rdoMultiplication.Name = "rdoMultiplication";
this.rdoMultiplication.Size = new System.Drawing.Size(96, 23);
this.rdoMultiplication.TabIndex = 2;
this.rdoMultiplication.TabStop = true;
this.rdoMultiplication.Text = "Multiplication";
this.rdoMultiplication.UseVisualStyleBackColor = true;
this.rdoMultiplication.CheckedChanged += new System.EventHandler(this.rdoMultiplication_CheckedChanged);
//
// rdoSubtraction
//
this.rdoSubtraction.Location = new System.Drawing.Point(26, 62);
this.rdoSubtraction.Name = "rdoSubtraction";
this.rdoSubtraction.Size = new System.Drawing.Size(86, 23);
this.rdoSubtraction.TabIndex = 1;
this.rdoSubtraction.TabStop = true;
this.rdoSubtraction.Text = "Subtraction";
this.rdoSubtraction.UseVisualStyleBackColor = true;
this.rdoSubtraction.CheckedChanged += new System.EventHandler(this.rdoSubtraction_CheckedChanged);
//
// rdoAddition
//
this.rdoAddition.Location = new System.Drawing.Point(26, 33);
this.rdoAddition.Name = "rdoAddition";
this.rdoAddition.Size = new System.Drawing.Size(77, 23);
this.rdoAddition.TabIndex = 0;
this.rdoAddition.TabStop = true;
this.rdoAddition.Text = "Addition";
this.rdoAddition.UseVisualStyleBackColor = true;
this.rdoAddition.CheckedChanged += new System.EventHandler(this.rdoAddition_CheckedChanged);
//
// pnlSummary
//
this.pnlSummary.Controls.Add(this.lblNumIncorrect);
@ -110,6 +127,36 @@
this.pnlSummary.Size = new System.Drawing.Size(197, 102);
this.pnlSummary.TabIndex = 2;
//
// lblNumIncorrect
//
this.lblNumIncorrect.Location = new System.Drawing.Point(96, 50);
this.lblNumIncorrect.Name = "lblNumIncorrect";
this.lblNumIncorrect.Size = new System.Drawing.Size(75, 20);
this.lblNumIncorrect.TabIndex = 3;
//
// lblNumCorrect
//
this.lblNumCorrect.Location = new System.Drawing.Point(15, 50);
this.lblNumCorrect.Name = "lblNumCorrect";
this.lblNumCorrect.Size = new System.Drawing.Size(75, 20);
this.lblNumCorrect.TabIndex = 2;
//
// lblDisIncorrect
//
this.lblDisIncorrect.Location = new System.Drawing.Point(96, 13);
this.lblDisIncorrect.Name = "lblDisIncorrect";
this.lblDisIncorrect.Size = new System.Drawing.Size(75, 20);
this.lblDisIncorrect.TabIndex = 1;
this.lblDisIncorrect.Text = "Incorrect:";
//
// lblDisCorrect
//
this.lblDisCorrect.Location = new System.Drawing.Point(15, 15);
this.lblDisCorrect.Name = "lblDisCorrect";
this.lblDisCorrect.Size = new System.Drawing.Size(75, 20);
this.lblDisCorrect.TabIndex = 0;
this.lblDisCorrect.Text = "Correct:";
//
// pnlCalc
//
this.pnlCalc.Controls.Add(this.lblImage);
@ -128,6 +175,56 @@
this.pnlCalc.Size = new System.Drawing.Size(698, 155);
this.pnlCalc.TabIndex = 3;
//
// lblImage
//
this.lblImage.Location = new System.Drawing.Point(508, 37);
this.lblImage.Name = "lblImage";
this.lblImage.Size = new System.Drawing.Size(47, 44);
this.lblImage.TabIndex = 10;
//
// btnReset
//
this.btnReset.Location = new System.Drawing.Point(592, 122);
this.btnReset.Name = "btnReset";
this.btnReset.Size = new System.Drawing.Size(105, 28);
this.btnReset.TabIndex = 9;
this.btnReset.Text = "Reset";
this.btnReset.UseVisualStyleBackColor = true;
//
// btnClear
//
this.btnClear.Location = new System.Drawing.Point(592, 88);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(105, 28);
this.btnClear.TabIndex = 8;
this.btnClear.Text = "Clear";
this.btnClear.UseVisualStyleBackColor = true;
//
// btnShowCorrectAnswer
//
this.btnShowCorrectAnswer.Location = new System.Drawing.Point(592, 54);
this.btnShowCorrectAnswer.Name = "btnShowCorrectAnswer";
this.btnShowCorrectAnswer.Size = new System.Drawing.Size(105, 28);
this.btnShowCorrectAnswer.TabIndex = 7;
this.btnShowCorrectAnswer.Text = "Show Correct";
this.btnShowCorrectAnswer.UseVisualStyleBackColor = true;
//
// btnChkAnswer
//
this.btnChkAnswer.Location = new System.Drawing.Point(592, 20);
this.btnChkAnswer.Name = "btnChkAnswer";
this.btnChkAnswer.Size = new System.Drawing.Size(105, 28);
this.btnChkAnswer.TabIndex = 6;
this.btnChkAnswer.Text = "Check Answer";
this.btnChkAnswer.UseVisualStyleBackColor = true;
//
// lblMessage
//
this.lblMessage.Location = new System.Drawing.Point(425, 101);
this.lblMessage.Name = "lblMessage";
this.lblMessage.Size = new System.Drawing.Size(77, 24);
this.lblMessage.TabIndex = 5;
//
// lblOperator
//
this.lblOperator.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@ -168,56 +265,6 @@
this.txtA.Size = new System.Drawing.Size(79, 20);
this.txtA.TabIndex = 0;
//
// rdoLvl2
//
this.rdoLvl2.Location = new System.Drawing.Point(28, 56);
this.rdoLvl2.Name = "rdoLvl2";
this.rdoLvl2.Size = new System.Drawing.Size(109, 18);
this.rdoLvl2.TabIndex = 1;
this.rdoLvl2.TabStop = true;
this.rdoLvl2.Text = "Level 2 (11-100)";
this.rdoLvl2.UseVisualStyleBackColor = true;
//
// rdoAddition
//
this.rdoAddition.Location = new System.Drawing.Point(26, 33);
this.rdoAddition.Name = "rdoAddition";
this.rdoAddition.Size = new System.Drawing.Size(77, 23);
this.rdoAddition.TabIndex = 0;
this.rdoAddition.TabStop = true;
this.rdoAddition.Text = "Addition";
this.rdoAddition.UseVisualStyleBackColor = true;
//
// rdoSubtraction
//
this.rdoSubtraction.Location = new System.Drawing.Point(26, 62);
this.rdoSubtraction.Name = "rdoSubtraction";
this.rdoSubtraction.Size = new System.Drawing.Size(86, 23);
this.rdoSubtraction.TabIndex = 1;
this.rdoSubtraction.TabStop = true;
this.rdoSubtraction.Text = "Subtraction";
this.rdoSubtraction.UseVisualStyleBackColor = true;
//
// rdoMultiplication
//
this.rdoMultiplication.Location = new System.Drawing.Point(109, 30);
this.rdoMultiplication.Name = "rdoMultiplication";
this.rdoMultiplication.Size = new System.Drawing.Size(96, 23);
this.rdoMultiplication.TabIndex = 2;
this.rdoMultiplication.TabStop = true;
this.rdoMultiplication.Text = "Multiplication";
this.rdoMultiplication.UseVisualStyleBackColor = true;
//
// rdoDivision
//
this.rdoDivision.Location = new System.Drawing.Point(109, 62);
this.rdoDivision.Name = "rdoDivision";
this.rdoDivision.Size = new System.Drawing.Size(77, 23);
this.rdoDivision.TabIndex = 3;
this.rdoDivision.TabStop = true;
this.rdoDivision.Text = "Division";
this.rdoDivision.UseVisualStyleBackColor = true;
//
// chkShowSummary
//
this.chkShowSummary.Location = new System.Drawing.Point(559, 213);
@ -228,86 +275,6 @@
this.chkShowSummary.UseVisualStyleBackColor = true;
this.chkShowSummary.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
//
// lblMessage
//
this.lblMessage.Location = new System.Drawing.Point(425, 101);
this.lblMessage.Name = "lblMessage";
this.lblMessage.Size = new System.Drawing.Size(77, 24);
this.lblMessage.TabIndex = 5;
//
// btnChkAnswer
//
this.btnChkAnswer.Location = new System.Drawing.Point(592, 20);
this.btnChkAnswer.Name = "btnChkAnswer";
this.btnChkAnswer.Size = new System.Drawing.Size(105, 28);
this.btnChkAnswer.TabIndex = 6;
this.btnChkAnswer.Text = "Check Answer";
this.btnChkAnswer.UseVisualStyleBackColor = true;
//
// btnShowCorrectAnswer
//
this.btnShowCorrectAnswer.Location = new System.Drawing.Point(592, 54);
this.btnShowCorrectAnswer.Name = "btnShowCorrectAnswer";
this.btnShowCorrectAnswer.Size = new System.Drawing.Size(105, 28);
this.btnShowCorrectAnswer.TabIndex = 7;
this.btnShowCorrectAnswer.Text = "Show Correct";
this.btnShowCorrectAnswer.UseVisualStyleBackColor = true;
//
// btnClear
//
this.btnClear.Location = new System.Drawing.Point(592, 88);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(105, 28);
this.btnClear.TabIndex = 8;
this.btnClear.Text = "Clear";
this.btnClear.UseVisualStyleBackColor = true;
//
// btnReset
//
this.btnReset.Location = new System.Drawing.Point(592, 122);
this.btnReset.Name = "btnReset";
this.btnReset.Size = new System.Drawing.Size(105, 28);
this.btnReset.TabIndex = 9;
this.btnReset.Text = "Reset";
this.btnReset.UseVisualStyleBackColor = true;
//
// lblDisCorrect
//
this.lblDisCorrect.Location = new System.Drawing.Point(15, 15);
this.lblDisCorrect.Name = "lblDisCorrect";
this.lblDisCorrect.Size = new System.Drawing.Size(75, 20);
this.lblDisCorrect.TabIndex = 0;
this.lblDisCorrect.Text = "Correct:";
//
// lblDisIncorrect
//
this.lblDisIncorrect.Location = new System.Drawing.Point(96, 13);
this.lblDisIncorrect.Name = "lblDisIncorrect";
this.lblDisIncorrect.Size = new System.Drawing.Size(75, 20);
this.lblDisIncorrect.TabIndex = 1;
this.lblDisIncorrect.Text = "Incorrect:";
//
// lblNumCorrect
//
this.lblNumCorrect.Location = new System.Drawing.Point(15, 50);
this.lblNumCorrect.Name = "lblNumCorrect";
this.lblNumCorrect.Size = new System.Drawing.Size(75, 20);
this.lblNumCorrect.TabIndex = 2;
//
// lblNumIncorrect
//
this.lblNumIncorrect.Location = new System.Drawing.Point(96, 50);
this.lblNumIncorrect.Name = "lblNumIncorrect";
this.lblNumIncorrect.Size = new System.Drawing.Size(75, 20);
this.lblNumIncorrect.TabIndex = 3;
//
// lblImage
//
this.lblImage.Location = new System.Drawing.Point(508, 37);
this.lblImage.Name = "lblImage";
this.lblImage.Size = new System.Drawing.Size(47, 44);
this.lblImage.TabIndex = 10;
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(675, 371);
@ -338,10 +305,8 @@
this.Controls.Add(this.pnlCalc);
this.Controls.Add(this.pnlSummary);
this.Controls.Add(this.grpOperations);
this.Controls.Add(this.grpLevels);
this.Name = "Form1";
this.Text = "Form1";
this.grpLevels.ResumeLayout(false);
this.grpOperations.ResumeLayout(false);
this.pnlSummary.ResumeLayout(false);
this.pnlCalc.ResumeLayout(false);
@ -364,8 +329,6 @@
private System.Windows.Forms.Label lblNumCorrect;
private System.Windows.Forms.Label lblNumIncorrect;
private System.Windows.Forms.RadioButton rdoLvl1;
private System.Windows.Forms.RadioButton rdoLvl2;
private System.Windows.Forms.RadioButton rdoSubtraction;
private System.Windows.Forms.RadioButton rdoMultiplication;
private System.Windows.Forms.RadioButton rdoDivision;
@ -377,7 +340,6 @@
private System.Windows.Forms.TextBox txtC;
private System.Windows.Forms.Label lblDisEqual;
private System.Windows.Forms.GroupBox grpLevels;
private System.Windows.Forms.GroupBox grpOperations;
private System.Windows.Forms.Panel pnlSummary;
private System.Windows.Forms.Panel pnlCalc;

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics.Eventing.Reader;
using System.Drawing;
using System.Linq;
using System.Text;
@ -12,6 +13,12 @@ namespace ElementaryMathematics
{
public partial class Form1 : Form
{
private bool isAdd = false;
private bool isSubtract = false;
private bool isMultiply = false;
private bool isDivide = false;
public Form1()
{
InitializeComponent();
@ -37,5 +44,58 @@ namespace ElementaryMathematics
{
// throw new System.NotImplementedException();
}
private void ChangeOperator(string op)
{
isAdd = false;
isSubtract = false;
isMultiply = false;
isDivide = false;
if (op == "+")
{
isAdd = true;
lblOperator.Text = op;
}else if (op == "-")
{
isSubtract = true;
lblOperator.Text = op;
}else if (op == "*")
{
isMultiply = true;
lblOperator.Text = op;
}else if (op == "/")
{
isDivide = true;
lblOperator.Text = op;
}
else
{
lblOperator.Text = "";
}
}
private void rdoAddition_CheckedChanged(object sender, EventArgs e)
{
ChangeOperator("+");
}
private void rdoSubtraction_CheckedChanged(object sender, EventArgs e)
{
ChangeOperator("-");
}
private void rdoMultiplication_CheckedChanged(object sender, EventArgs e)
{
ChangeOperator("*");
}
private void rdoDivision_CheckedChanged(object sender, EventArgs e)
{
ChangeOperator("/");
}
}
}