当前位置: 首页>>代码示例>>C#>>正文


C# Cube.Area方法代码示例

本文整理汇总了C#中Cube.Area方法的典型用法代码示例。如果您正苦于以下问题:C# Cube.Area方法的具体用法?C# Cube.Area怎么用?C# Cube.Area使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cube的用法示例。


在下文中一共展示了Cube.Area方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

 public static void Main()
 {
    double x = 5.2;
    Square s = new Square(x);
    Square c = new Cube(x);
    Console.WriteLine("Area of Square = {0:F2}", s.Area());
    Console.WriteLine("Area of Cube = {0:F2}", c.Area());
 }
开发者ID:hattya,项目名称:ctags,代码行数:8,代码来源:input.cs

示例2: Main

 public static void Main()
 {
     double x = 5.2;
     Square s = new Square(x);
     Square c = new Cube(x);
     Console.WriteLine("Area of Square = {0}", string.Format("{0:0.00}", s.Area()));
     Console.WriteLine("Area of Cube = {0}", string.Format("{0:0.00}", c.Area()));
     Console.ReadLine();
 }
开发者ID:Nagato23,项目名称:CsBasic,代码行数:9,代码来源:overrideTest.cs

示例3: Main

        static void Main(string[] args)
        {
            List<TwoDim> twodim = new List<TwoDim>();
            List<ThreeDim> threedim = new List<ThreeDim>();
            while (true)
            {
                Console.WriteLine("도형종류 : Triangle, Square, Circle, Cube, Sphere");
                double number;
                Console.Write("단위 크기 : ");
                try
                {
                    number = Double.Parse(Console.ReadLine());
                    if (number<=0)
                    {
                        Console.WriteLine("잘못된 범위의 값을 입력하였습니다.");
                        continue;
                    }
                }
                catch (System.FormatException x)
                {
                    Console.WriteLine(x.Message);
                    continue;
                }
                catch (SystemException y)
                {
                    Console.WriteLine(y.Message);
                    continue;
                }

                Console.Write("모양 : ");

                string whatShape = Console.ReadLine();
                int count = 0;
                int i = 0;
                if (whatShape != "Triangle" && whatShape != "Square" && whatShape != "Circle"&&whatShape!="Cube"&&whatShape!="Sphere")
                {
                    Console.WriteLine("없는 도형입니다.");
                    continue;
                }
                else if (whatShape == "Triangle")
                {
                    TwoDim tri = new Triangle();
                    foreach (var item in twodim)
                    {
                        if (twodim[i].typeTwo == 3 && twodim[i].numTwo == number)
                        {
                            Console.WriteLine("이미 담은 도형입니다.");
                            count += 1;
                            break;
                        }
                        i++;
                    }
                    if (count == 0)
                    {
                        tri.typeTwo = 3;
                        tri.numTwo = number;
                        tri.Length(number);
                        tri.Area(number);
                        twodim.Add(tri);
                        i = 0;
                    }
                    count = 0;
                }
                else if (whatShape == "Square")
                {
                    TwoDim squ = new Square();
                    foreach (var item in twodim)
                    {
                        if (twodim[i].typeTwo == 4 && twodim[i].numTwo == number)
                        {
                            Console.WriteLine("이미 담은 도형입니다.");
                            count += 1;
                            break;
                        }
                        i++;
                    }
                    if (count == 0)
                    {
                        squ.typeTwo = 4;
                        squ.numTwo = number;
                        squ.Length(number);
                        squ.Area(number);
                        twodim.Add(squ);
                        i = 0;
                    }
                    count = 0;
                }
                else if (whatShape == "Circle")
                {
                    TwoDim cir = new Circle();
                    foreach (var item in twodim)
                    {
                        if (twodim[i].typeTwo == 0 && twodim[i].numTwo == number)
                        {
                            Console.WriteLine("이미 담은 도형입니다.");
                            count += 1;
                            break;
                        }
                        i++;
                    }
//.........这里部分代码省略.........
开发者ID:ahu8867,项目名称:Lab_20150715_shape,代码行数:101,代码来源:Program.cs


注:本文中的Cube.Area方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。