http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 2231|回复: 0

[其他] 我照着教材编的,为什么没有为0的初始化数据,求大神看看

[复制链接]
发表于 2013-7-16 10:37:36 | 显示全部楼层 |阅读模式
[code=csharp]using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace triArea3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        class Triangle
        {
            private double sideA;
            private double sideB;
            private double sideC;
            public Triangle()
            {
            }
            public Triangle(double sA)
            {
                sideA = sideB = sideC = sA;
            }
            public double SideA
            {
                get
                {
                    return sideA;
                }
                set
                {
                    sideA = value;
                }
            }
            public double SideB
            {
                get
                {
                    return sideB;
                }
                set
                {
                    sideB = value;
                }
            }
            public double SideC
            {
                get
                {
                    return sideC;
                }
                set
                {
                    sideC = value;
                }
            }
            public bool test()
            {
                if ((sideA + sideB > sideC) && (sideB + sideC > sideA) && (sideC + sideA > sideB))
                    return true;
                else
                    return false;
            }
            public double triCir()
            {
                double tCir = sideA + sideB + sideC;
                return tCir;
            }
            public double triArea()
            {
                double p = (sideA + sideB + sideC) / 2;
                double tarea = Math.Sqrt(p * (p - sideA) * (p - sideB) * (p - sideC));
                return tarea;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Triangle tri1 = new Triangle(0);
            double s1, s2, s3, trcir, trarea;
            bool t;
            s1 = double.Parse(textBox1.Text);
            s2 = double.Parse(textBox2.Text);
            s3 = double.Parse(textBox3.Text);
            tri1.SideA = s1;
            tri1.SideB = s2;
            tri1.SideC = s3;
            t = tri1.test();
            if (!t)
            {
                MessageBox.Show("不能构造成三角形请重新输入");
                textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = textBox5.Text = string.Empty;
                return;
            }
            trcir = tri1.triCir();
            trarea = tri1.triArea();
            textBox4.Text = trcir.ToString();
            textBox5.Text = trarea.ToString();
            if (tri1.SideA == tri1.SideB && tri1.SideB == tri1.SideC)
                textBox6.Text = "等边三角形边长为:" + tri1.SideA + "厘米";
            else
                textBox6.Text = "三角形三边长分别为:" + tri1.SideA + "厘米" + tri1.SideB + "厘米" + tri1.SideC + "厘米";
        }
        private void frmTriangle_Load(object sender, EventArgs e)
        {
            double s1, s2, s3, trcir, trarea;
            Triangle tri1 = new Triangle(0);
            s1 = double.Parse(textBox1.Text);
            s2 = double.Parse(textBox2.Text);
            s3 = double.Parse(textBox3.Text);
            textBox1.Text = s1.ToString();
            textBox2.Text = s3.ToString();
            textBox3.Text = s3.ToString();
            trcir = tri1.triCir();
            trarea = tri1.triArea();
            textBox4.Text = trcir.ToString();
            textBox5.Text = trcir.ToString();
            if (tri1.SideA == tri1.SideB && tri1.SideB == tri1.SideC)
                textBox6.Text = "等边三角形边长为:" + tri1.SideA + "厘米";
            else
                textBox6.Text = "三角形三边长分别为:" + tri1.SideA + "厘米" + tri1.SideB + "厘米" + tri1.SideC + "厘米";
        }
    }
}

[/code]


1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-6-2 00:57

© 2014-2021

快速回复 返回顶部 返回列表