?? 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 for 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 attribute. */
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;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -