using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSharpMethod
{
class Program
{
static void Main(string[] args)
{
Cylinder cylinder = new Cylinder();
cylinder.High = 12;
cylinder.Radius = 3;
Console.WriteLine("地面半径为{0},高为{1},体积为{2}。", cylinder.Radius, cylinder.High, cylinder.Volume());
}
}
public class Circle
{
private double radius;
public double Radius
{
set { radius = value >= 0 ? value : 0; }
get { return radius; }
}
public double Area()
{
return Math.PI * radius * radius;
}
}
public class Cylinder : Circle
{
private double high;
public double High
{
set { high = value >= 0 ? value : 0; }
get { return high; }
}
public double Volume()
{
return Area() * high;
}
}
}
网友评论