码迷,mamicode.com
首页 > Windows程序 > 详细

WPF应用

时间:2015-12-13 23:36:14      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:

代码

   private void button1_Click(object sender, RoutedEventArgs e)
        {
            calculate sa = new calculate(int.Parse(textBox1.Text),int.Parse(textBox3.Text),textBox2.Text);
            if (sa.answer == int.Parse(textBox4.Text))
            {
                MessageBox.Show("回答正确");
            }
            else
            {
                MessageBox.Show("回答错误");
            
            }
 interface chapter
    {
        int answer { get; }
    }
    class calculate:chapter
    {
           private int x1;
        private int x2;
        private string Operator;
        public int result;
        public calculate(int x1, int x2, string Operator)
        {
            this.x1 = x1;
            this.x2 = x2;
            this.Operator = Operator;
       

        }
        public int answer
        {
            get {

                if (Operator == "+")
                {
                    result = x1 + x2;

                }
                if (Operator == "-")
                {

                    result = x1 - x2;

                }
                if (Operator == "*")
                {

                    result = x1 * x2;

                }
                 if (Operator == "/")
                {

                    result = x1 / x2;

                }
                return result;
            }
        }

    }
}

技术分享

技术分享技术分享
 
总结:
 
在不同情况下运用封装的语句很容易,困难的是对设计模式的理解和运用现在正在思考如何运用。。

WPF应用

标签:

原文地址:http://www.cnblogs.com/fei2/p/5043758.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!