let turtle1 = new CircularTurtle()
let turtle2 = new RectangularTurtle()
let turtle3 = new EllipticalTurtle()
//Assume turtle is dynamic (probably through component/ivar, e.g., "shape") let turtle1 = new Turtle(); turtle1.setAsCircular(); let turtle2 = new Turtle(); turtle2.setAsRectangular(); let turtle3 = new Turtle(); turtle3.setAsElliptical(); "
//Assume turtle is dynamic (probably through component/ivar, e.g., "shape") let turtle1 = Turtle.newCircular(); let turtle1 = Turtle.newRectangular(); let turtle1 = Turtle.newElliptical();
setAsCircular() { this.setShape(new Circle()); } setAsRectangular() { this.setShape(new Rectangle()); } setAsElliptical() { this.setShape(new Ellipse()); }
static newCircular() { let turtle = new Turtle(); turtle.setShape(new Circular()); return turtle; } //Similar for other two