赞
踩
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;
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。