I can:
write constructors for subclasses
public class Main
{
public static void main(String[] args)
{
Rectangle r = new Rectangle(3,5);
r.draw();
// D. Uncomment these to test
// Square s1 = new Square();
// s1.draw();
// Square s = new Square(3);
// s.draw();
}
}
class Rectangle
{
private int length;
private int width;
public Rectangle()
{
length = 1;
width = 1;
}
public Rectangle(int l, int w)
{
length = l;
width = w;
}
public void draw()
{
for(int i=0; i < length; i++)
{
for(int j=0; j < width; j++)
System.out.print("* ");
System.out.println();
}
System.out.println();
}
}
// A. Make the class square inherit from Rectangle
public class Square
{
// B. Add a Square no-argument constructor
// C. Add a Square constructor with 1 argument for a side
}