| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 602 人关注过本帖
标题:各位帮帮忙,我不是很懂重写这块,在此感激不尽
只看楼主 加入收藏
雪月
Rank: 1
来 自:甘肃兰州
等 级:新手上路
帖 子:13
专家分:0
注 册:2012-11-19
结帖率:33.33%
收藏
 问题点数:0 回复次数:4 
各位帮帮忙,我不是很懂重写这块,在此感激不尽
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 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 radius)
        {
            double area = PI * radius * radius;
            return Console.ReadLine(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 length,double width)
        {
            double area = length * width;
            return Console.WriteLine(area)  ;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            circle S1=new circle(4);
            S1.Area();

            rectangle  S2= new rectangle (4.6);
            S2.Area();
            
        }
    }
}
搜索更多相关主题的帖子: public double return 
2013-11-28 14:26
雪月
Rank: 1
来 自:甘肃兰州
等 级:新手上路
帖 子:13
专家分:0
注 册:2012-11-19
收藏
得分: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();
        }
    }
}

永不言弃>-<持之以恒
2013-11-28 20:39
lclc309
Rank: 1
等 级:新手上路
帖 子:5
专家分:5
注 册:2013-5-13
收藏
得分:0 
什么错误?是不是没有输出!你弄两个double型都变量接受area,然后输出应该行!
2013-12-03 18:14
黄占林
Rank: 1
等 级:新手上路
威 望:1
帖 子:4
专家分:5
注 册:2014-1-25
收藏
得分:0 
public double ShowArea()
            {
                Console.WriteLine("面积为{0}", area);
                return area;
            }
---------------------------------------------------------------------
public void double ShowArea()
            {
                Console.WriteLine("面积为{0}", area);
            }
2014-01-25 01:37
有容就大
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:东土大唐
等 级:版主
威 望:74
帖 子:9048
专家分:14309
注 册:2011-11-11
收藏
得分:0 
有什么具体的问题吗》

梅尚程荀
马谭杨奚







                                                       
2014-01-26 23:15
快速回复:各位帮帮忙,我不是很懂重写这块,在此感激不尽
数据加载中...
 
   



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

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