verybasicbox.java
来自「国外的数据结构与算法分析用书」· Java 代码 · 共 30 行
JAVA
30 行
/** A simple box class with variables for the length, width, and height,
and a method to compute its volume. */
public class VeryBasicBox
{
/** Instance variables of the class. */
int length, width, height;
/** Method for returning the volume of the box. */
public int volume()
{
int vol;
vol = length * width * height;
return vol;
}
/** Constructor to create an object and initialize its variables. */
public VeryBasicBox(int l, int w, int h)
{
length = l;
width = w;
height = h;
}
/** Does this box have equal variable values as box other? */
public boolean equals(VeryBasicBox other)
{
return (length==other.length) && (width==other.width) && (height==other.height);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?