| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 310 人关注过本帖
标题:计算器的设计中为什么类中的public的函数不可用???
取消只看楼主 加入收藏
爱文
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-5-29
收藏
 问题点数:0 回复次数:0 
计算器的设计中为什么类中的public的函数不可用???
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace WindowsFormsApplication11
{

    public partial class Form1 : Form
    {
        public string a;
        public string b;
        jisuanqi ji = new jisuanqi();
        string n = "";
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = richTextBox1.Text+"1";
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = richTextBox1.Text+"2";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = richTextBox1.Text+"3";
        }

        private void button4_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = richTextBox1.Text+"4";
        }

        private void button5_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = richTextBox1.Text+"5";
        }

        private void button6_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = richTextBox1.Text+"6";
        }

        private void button7_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = richTextBox1.Text + "7";
        }

        private void button8_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = richTextBox1.Text + "8";
        }

        private void button9_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = richTextBox1.Text + "9";
        }

        private void button10_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = richTextBox1.Text + "0";
        }

        private void button11_Click(object sender, EventArgs e)
        {
            a= richTextBox1.Text;
            richTextBox1.Text = " ";
            n = "-";
        }

        private void button12_Click(object sender, EventArgs e)
        {
            a= richTextBox1.Text;
            richTextBox1.Text = " ";
            n = "*";
        }

        private void button13_Click(object sender, EventArgs e)
        {
            a = richTextBox1.Text;
            richTextBox1.Text = " ";
            n = "/";
        }

        private void button14_Click(object sender, EventArgs e)
        {
            a = richTextBox1.Text;
            n = "sqrt";
            richTextBox1.Text = " ";
        }

        private void button15_Click(object sender, EventArgs e)
        {
            a= richTextBox1.Text;
            n = "fushu";
            richTextBox1.Text = " ";
        }

        private void button16_Click(object sender, EventArgs e)
        {
            b = richTextBox1.Text;
            richTextBox1.Text = "=";
            switch (n)
            {
                case "+": richTextBox1.Text = (ji.yunsuanjia( a, b)).ToString(); break;
                case "-": richTextBox1.Text = (ji.yunsuanjian(a, b)).ToString(); break;
                case "*": richTextBox1.Text = (ji.yunsuancheng(a, b)).ToString(); break;
                case "/": richTextBox1.Text = (ji.yunsuanchu(a, b)).ToString(); break;
                case "sqrt": richTextBox1.Text = (ji.kaifang(a).ToString()); break;
            }
        }
            

        private void button17_Click(object sender, EventArgs e)
        {
            a= richTextBox1.Text;
            n = "+";
            richTextBox1.Text = " ";
        }

        
    }
    public class jisuanqi
    {
        
        public int yunsuanjia(string a, string b)
        {
            int c = Convert.ToInt32(a) + Convert.ToInt32(b);
            return c;

        }
        public int yusuanjian(string a, string b)
        {
            int c = Convert.ToInt32(a) - Convert.ToInt32(b);
            return c;
        }
        public int yusuancheng(string a, string b)
        {
            int c = Convert.ToInt32(a) * Convert.ToInt32(b);
            return c;
        }
        public int yusuanchu(string a, string b)
        {
            int c = Convert.ToInt32(a) / Convert.ToInt32(b);
            return c;
        }
        public int kaifang(string a)
        {
            int c = Convert.ToInt32(Math.Sqrt(Convert.ToInt32(a)));
            return c;
        }
   
   
        
    }
   

}
2013-06-05 21:20
快速回复:计算器的设计中为什么类中的public的函数不可用???
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017305 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved