Help, I can't seem to get an output from my inherited shape, whats is wrong with my code? Anyone? I have shortened the code to exclude all the extra constructors and getters and setters, but I hope this provides enough context.
public class Shape {
public String color;
public Boolean filled;
public Shape(String color, Boolean filled) {
this.color = color;
this.filled = filled;
}
public String toString() {
retu "Shape[color = " + color + "filled = " + filled;
}
-----------------------------------------
public class Rectangle extends Shape {
public double width;
public double length;
public Rectangle(double width, double length) {
this.width = width;
this.length = length;
}
@Override
public String toString() {
retu "A Rectangle with width = " + width + "and length = " + length;
}
}
-----------------------------------------
public class TestShape {
public static void main(String[] args) {
Shape s1 = new Shape();
System.out.println(s1);
}
Shape r1 = new Rectangle(1.0, 2.0);
System.out.println(r1); // Why is there an error?
