topical media & game development

talk show tell print

actionscript-book-GeometricShapes-com-example-programmingas3-geometricshapes-Circle.ax

actionscript-book-GeometricShapes-com-example-programmingas3-geometricshapes-Circle.ax [swf] flex


  package 
  {
  
          public class @ax-actionscript-book-GeometricShapes-com-example-programmingas3-geometricshapes-Circle implements actionscript_book_GeometricShapes_com_example_programmingas3_geometricshapes_IGeometricShape 
          {
                  public var diameter:Number;
                  
                  public function @ax-actionscript-book-GeometricShapes-com-example-programmingas3-geometricshapes-Circle(diam:Number = 100):void
                  {
                          this.diameter = diam;
                  }
                  
                  public function getArea():Number
                  {
                      // the formula is Pi * radius * radius
                          var radius:Number = diameter / 2;
                      return Math.PI * radius * radius;
                  }
                  
                  public function getCircumference():Number
                  {
                      // the formula is Pi * diameter
                      return Math.PI * diameter;
                  }
                  
                  public function describe():String
                  {
                      var desc:String = "This shape is a @ax-actionscript-book-GeometricShapes-com-example-programmingas3-geometricshapes-Circle.\n";
              desc += "Its diameter is " + diameter + " pixels.\n";
              desc += "Its area is " + getArea() + ".\n";;
              desc += "Its circumference is " + getCircumference() + ".\n"; 
              
              return desc;  
                  }
          }
  }


(C) Æliens 27/08/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.