• 老陈和小石头


    namespace 小石头和老陈
    {
         
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            public static int Count = 0;//题目总数
            public static int right = 0;//正确的题目总数
            public static int connt = 0;//错误题目数
            int j = 0;
            string  a;
            string  b;
            int  c;
    
            private void label3_Click(object sender, EventArgs e)
            {
                tb4.Text = "+";
            }
    
            private void label4_Click(object sender, EventArgs e)
            {
                tb4.Text = "-";
            }
    
            private void label5_Click(object sender, EventArgs e)
            {
                tb4.Text = "*";
            }
            private void label6_Click(object sender, EventArgs e)
            {
                tb4.Text = "/";
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                a = textBox6.Text;
                b = textBox8.Text;
                string str = textBox7.Text;
                switch (str)
                {
                    case "+":
    
                        Class1 j = new Class1();
                        j.ji(a, b, out c);
                        break;
                    case "-":
                        Class1 j2 = new Class1();
                        j2.ji2(a, b, out c);
                        break;
                    case "*":
                        Class1 j3 = new Class1();
                        j3.ji3(a, b, out c);
                        break;
                    case "/":
                        Class1 j4 = new Class1();
                        j4.ji4(a, b, out c);
                        break;
                }
                if (textBox8.Text == "" || textBox6.Text == "")//当没有导入题时不能记到总做的题数;
                {
                    MessageBox.Show("不能为空");
                    Count--;
    
                }
                else if (textBox3.Text == c.ToString())
                {
                    right++;
                    MessageBox.Show("回答正确!");
                }
                else if (textBox3.Text != c.ToString())
                {
    
                    connt++;
                    MessageBox.Show("回答错误!");
                }
    
                Count++;
    
                textBox6.Clear();
                textBox7.Clear();
                textBox8.Clear();
                textBox3.Clear();
                textBox1.Text = Count.ToString();
                
            }
               
            private void button2_Click(object sender, EventArgs e)
            {
                   Form2 form = new Form2();
                    form.ShowDialog();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                //保存家长出的数学题
                StreamWriter wr = File.AppendText("g1.txt");
                wr.WriteLine(tb1.Text );
                wr.Close();
                StreamWriter wr1 = File.AppendText("g2.txt");
                wr1.WriteLine(tb2.Text);
                wr1.Close();
                StreamWriter wr2 = File.AppendText("g3.txt");
                wr2.WriteLine(tb4.Text);
                wr2.Close();
                tb1.Clear();
                tb2.Clear();
                tb4.Clear();
            }
    
            private void button4_Click(object sender, EventArgs e)
            {
                try//防止出现异常,当题做完直接跳转到Form2窗体,,,,
                {
                    j++;
                    string[] jg = new string[100];
                    jg = File.ReadAllLines("g1.txt");
                    textBox6.Text = jg[j];
                    string[] jg2 = new string[100];
                    jg2 = File.ReadAllLines("g3.txt");
                    textBox7.Text = jg2[j];
                    string[] jg3 = new string[100];
                    jg3 = File.ReadAllLines("g2.txt");
                    textBox8.Text = jg3[j];
                    if (jg2[j] =="/"&& jg3 [j]=="0")
                    {
                        MessageBox.Show("分母不能为零");//判断分母是否为零,
                        j++;
                        textBox6.Clear();
                        textBox7.Clear();
                        textBox8.Clear();
                    }
                }
                catch
                {
                    Form2 form = new Form2();
                    form.ShowDialog();
                }
            }
    
            private void button5_Click(object sender, EventArgs e)
            {
                Form3 form3 = new Form3();
                form3.ShowDialog();
            }
        }       
      }

    定义一个Class1类

    namespace 小石头和老陈
    {
        class Class1
        {
            public void ji(string x, string y, out int s)
            {
                s = int.Parse(x) + int.Parse(y);
            }
            public void ji2(string x, string y, out int s)
            {
                s = int.Parse(x) - int.Parse(y);
            }
            public void ji3(string x, string y, out int s)
            {
                s = int.Parse(x) * int.Parse(y);
            }
            public void ji4(string x, string y, out int s)
            {
                s = int.Parse(x) / int.Parse(y);
            }
        }
    }








    PSP消耗


  • 相关阅读:
    数据流控制
    转:简单的Mysql主从复制设置
    转:CentOS---网络配置详解
    Linux-vim学习入门
    Linux图形界面与字符界面切换
    转:MySQL表名不区分大小写
    CentOS6.5_x86安装Mysql5.5.49
    Linux的环境变量设置和查看
    Linux防火墙的关闭和开启
    Linux command not found 问题解释
  • 原文地址:https://www.cnblogs.com/mengq/p/5008111.html
Copyright © 2020-2023  润新知