📄 basicbox.java
字号:
/** A simple box class with variables for the length, width, and height,
and methods to return its volume, a string representation of the box,
and test for equality. */
public class BasicBox
{
/** Instance variables the class. */
int length, width, height;
/** Constructor for a box. */
public BasicBox(int l, int w, int h)
{
length = l;
width = w;
height = h;
}
/** Method for returning the volume of the box. */
public int volume()
{
return length * width * height;
}
/** A string representation of the box formed by appending a string
representation of each atribute. */
public String toString()
{
String temp = " Length = " + length + "\n"
+ " Width = " + width + "\n"
+ " Height = " + height + "\n";
return temp;
}
/** Does this box have equal variable values as box other? */
public boolean equals(BasicBox other)
{
return length == other.length & width == other.width & height == other.height;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -