class Glyph{
void draw(){System.out.println("Glyph.draw()");}
Glyph(){
System.out.println("Glyph() before draw()");
draw();
System.out.println("Glyph() after draw()");
}
}
class RoundGlyph extends Glyph {
private int radius=1;
RoundGlyph(int r){
radius=r;
System.out.println("Round.Round() ,radius= "+radius);
}
void draw(){System.out.println("RoundGlyph.draw(), radius= "+radius);}
}
class RectangularGlyph extends Glyph{
private int length=2;
private int weidth=3;
RectangularGlyph(int a,int b){
length=a;weidth=b;
System.out.println("Rectangular.Rectangular() ,"
+ "length= "+length+";weidth= "+weidth);
}
void draw(){System.out.println("Rectangular.draw() ,"
+ "length= "+length+";weidth= "+weidth);}
}
public class PolyConstructors {
public static void main(String[] args) {
new RoundGlyph(5);
new RectangularGlyph(9,16);
}
}
void draw(){System.out.println("Glyph.draw()");}
Glyph(){
System.out.println("Glyph() before draw()");
draw();
System.out.println("Glyph() after draw()");
}
}
class RoundGlyph extends Glyph {
private int radius=1;
RoundGlyph(int r){
radius=r;
System.out.println("Round.Round() ,radius= "+radius);
}
void draw(){System.out.println("RoundGlyph.draw(), radius= "+radius);}
}
class RectangularGlyph extends Glyph{
private int length=2;
private int weidth=3;
RectangularGlyph(int a,int b){
length=a;weidth=b;
System.out.println("Rectangular.Rectangular() ,"
+ "length= "+length+";weidth= "+weidth);
}
void draw(){System.out.println("Rectangular.draw() ,"
+ "length= "+length+";weidth= "+weidth);}
}
public class PolyConstructors {
public static void main(String[] args) {
new RoundGlyph(5);
new RectangularGlyph(9,16);
}
}