using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _4_4
{
public partial class Form1 : Form
{
area rr = new area();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
rr.Banjing = double.Parse(textBox1.Text);
textBox2.Text = rr.Mianji().ToString();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Text = "圆的面积";
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
}
}
public class area
{
private double banjing=0;
public double Banjing
{
get
{
return banjing;
}
set
{
banjing = value;
}
}
public double Mianji()
{
return 3.14 * banjing * banjing;
}
}
}
建立Windows窗体应用程序,在默认窗体Form1中添加两个TextBox控件,分别用来输入圆半径和显示圆面积;添加一个Button控件,用来根据输入的圆半径计算圆面积。
最新推荐文章于 2022-05-12 10:05:39 发布