标题:哪位大神看看哪错了
取消只看楼主
雪月
Rank: 1
来 自:甘肃兰州
等 级:新手上路
帖 子:13
专家分:0
注 册:2012-11-19
结帖率:33.33%
 问题点数:0 回复次数:0 
哪位大神看看哪错了
class Program
    {

        public class shap
        {
            public double area;
            public virtual double Area(double S)
            {
                this.area = S;
                return S;
            }
            public double ShowArea()
            {
                Console.WriteLine("面积为{0}", area);
                return area;
            }
            public virtual double Area()
            {
                return area;
            }
            public shap(double d)
            {
                area = d;
            }
        }
        public class circle : shap          //子类
        {
            double radius;
            public const double PI = 3.1416;
            public circle(double S, double R)    //继承
                : base(S)
            {
                this.area=S;
                this.radius = R;

            }
            public override double Area()
            {
                double area = PI * radius * radius;
                //return Console.ReadLine(area);
                return area;
            }
        }
        public class rectangle : shap        //子类
        {
            double length;
            double width;
            public rectangle(double S, double L, double W)   //继承
                : base(S)
            {
                this.area = S;
                this.length = L;
                this.width = W;

            }
            public override double Area()  //重写
            {
                double area = length * width;
                //return Console.WriteLine(area);
                return area;
            }
        }

        static void Main(string[] args)
        {

            //circle S1 = new circle(" ", 4);//
            circle S1 = new circle(2, 4);
            S1.Area();

            //rectangle S2 = new rectangle(" ", 4, 6);
            rectangle S2 = new rectangle(0, 4, 6);

            S2.Area();
            Console.ReadKey();
        }
    }
}
搜索更多相关主题的帖子: public double return 
2013-11-28 20:44



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-424368-1-1.html




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

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