3.定义一个圆柱类Cylinder,包括底面积半径和高两个数据成员:包含底面半径和搞两个数据成员:包含一个可以读取和设置个数据成员的值,包含一个可以计算圆柱体积的方法。编写相关程序测试功能…
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Homework114_3
{
class Cylinder
{
private int r;
private int h;
public int R
{
get {
return r;
}
set {
r = value;
}
}
public int H
{
get
{
return h;
}
set
{
h = value;
}
}
public double area()
{
double s1;
return s1 = 2 * 3.14 * r * h;
}
public static void Main()
{
Cylinder c = new Cylinder();
c.R = 2;
c.H = 2;
int r1 = c.R;
int h1 = c.H;
Console.WriteLine(c.area());
Console.Read();
}
}
}