hello everyone, I am new to java programming and i am currently studying inheritance.
I have following program and i am getting error "cannot find symbol" .Please help me.Thanks in advance.
class Box {
double width;
double height;
double depth;
Box() { //default constructor
width = 0;
height = 0;
depth = 0;
}
Box(double w, double h,double d) { //parametrised constructor
width = w;
height = h;
depth = d;
}
Box(double x) { // for cube
width = height = depth = x;
}
Box(Box ob) { //constructor which clones
width = ob.width;
height = ob.height;
depth = ob.depth;
}
double volume() {
return width * height * depth;
}
}
class BoxWeight extends Box {
private double weight;
BoxWeight(double w, double h, double d, double m) {
super(w, h, d);
weight = m;
}
double GetBoxWeight() {
return weight;
}
}
class boxinheritance {
public static void main(String args[]) {
Box mybox = new Box();
BoxWeight b2 = new BoxWeight(10,15,20,50);
System.out.println("Box b1 volume = " + mybox.volume);
System.out.println("Box b2 volume = " + b2.volume);
System.out.println("Box b1 weight = " + b2.GetBoxWeight);
}
}