当前位置:   article > 正文

c@简单实例

c@

using System;

 

public class HelloWorld

{

    static public void Main ()

    {

     //Instantiating the Box class defined below

        Box myBox = new Box(); // Declare myBox of type Box

        myBox.setDimensions(6.0,7.0,5.0);

        double volume = myBox.getVolume();

        Console.WriteLine("Volume of myBox : {0}", volume);

    }

}

 

 

class Box {

 

    private double length; // Length of a box

    private double breadth; // Breadth of a box

    private double height; // Height of a box

 

    public void setDimensions( double length, double breath, double height ) {

        this.length = length;

        this.breadth = breath;

        this.height = height;

    }

 

    public double getVolume() {

        return length * breadth * height;

    }

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/237938
推荐阅读
相关标签
  

闽ICP备14008679号