testbox.java
来自「国外的数据结构与算法分析用书」· Java 代码 · 共 35 行
JAVA
35 行
class TestBox
{
static void main(String args[])
{
BasicBox box1 = new BasicBox(4, 5, 6);
BasicBox box2 = new BasicBox(2, 3, 4);
System.out.println("The volume of box1 is " + box1.volume());
System.out.println("The volume of box2 is " + box2.volume());
ColorBox box3 = new ColorBox(10, 20, 30);
ColorBox box4 = new ColorBox(10, 20, 30, "green");
System.out.println(box3);
System.out.println(box4);
BasicBox box5 = new BasicBox(10, 20, 20);
System.out.println(box5);
box5.length = 5000;
System.out.println(box5);
if (box1.equals(box2))
System.out.println("box1 equals box2");
else
System.out.println("box1 does not equal box2");
if (box3.equals(box4))
System.out.println("box3 equals box4");
else
System.out.println("box3 does not equal box4");
ColorBox box6 = new ColorBox(10, 20, 30);
if (box3.equals(box6))
System.out.println("box3 equals box6");
else
System.out.println("box3 does not equal box6");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?