package{ import flash.display.Sprite; public class Main extends Sprite{ public function Main(){ var r = new Rectangle( ); r.setSize(4,5); trace(r.getArea( )); var s = new Square( ); s.setSize(4,5); trace (s.getArea()); } }}class Rectangle { protected var w = 0; protected var h = 0; public function setSize (newW, newH) { w = newW; h = newH; } public function getArea ( ) { return w * h; }}class Square extends Rectangle { override public function setSize (newW, newH) { if (newW == newH) { w = newW; h = newH; } }}
Name (required)
email (will not be published) (required)
Website