📄 refdemo.java
字号:
//Sample2
class Box
{
double width;
double height;
double depth;
Box()
{
width = height = depth = -1;
}
Box(double len)
{
width = height = depth = len;
}
Box(double w, double h, double d)
{
width = w;
height = h;
depth = d;
}
double volume()
{
return width*height*depth;
}
}
class boxWeight extends Box
{
double weight;
boxWeight(double w, double h, double d, double wh)
{
width = w;
height = h;
depth = d;
weight = wh;
}
double volume()
{
return width*height*depth*weight;
}
}
class refDemo
{
public static void main(String args[])
{
boxWeight weightbox = new boxWeight(1,2,3,4);
Box plainbox = new Box();
double vol;
vol = weightbox.volume();
System.out.println(vol);
System.out.println("Weight:" + weightbox.weight);
// weightbox = plainbox;2004.10.22
// vol = weightbox.volume();这样是不行的!!!
plainbox = weightbox;
vol = plainbox.volume();
System.out.println(vol);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -