topical media & game development

talk show tell print

actionscript-zoo-final-src-zoo-Apple.ax

actionscript-zoo-final-src-zoo-Apple.ax (swf ) [ flash ] flex


  package zoo {
    // The actionscript-zoo-final-src-zoo-Apple class represents one of the types of food a pet can eat
    public class actionscript-zoo-final-src-zoo-Apple extends Food {
      // The amount of calories in an actionscript-zoo-final-src-zoo-Apple object, if no specific 
      // amount is indicated
      private static var DEFAULT_CALORIES:int = 100;
      // Tracks whether an actionscript-zoo-final-src-zoo-Apple object has a worm
      private var wormInactionscript-zoo-final-src-zoo-Apple:Boolean;
    
      // Constructor
      public function actionscript-zoo-final-src-zoo-Apple (initialCalories:int = 0) {
        // If no valid calorie amount is specified...
        if (initialCalories <= 0) {
          // ...give this actionscript-zoo-final-src-zoo-Apple object the default amount
          initialCalories = actionscript-zoo-final-src-zoo-Apple.DEFAULT_CALORIES;
        }
        // Invoke the Food class constructor
        super(initialCalories);
  
        // Randomly determine whether this actionscript-zoo-final-src-zoo-Apple object as a worm (50% chance)
        wormInactionscript-zoo-final-src-zoo-Apple = Math.random() >= .5;
        
        // Give this food item a name
        setName("actionscript-zoo-final-src-zoo-Apple");
      }
  
      // Returns a Boolean indicating whether the actionscript-zoo-final-src-zoo-Apple object has a worm
      public function hasWorm ():Boolean {
        return wormInactionscript-zoo-final-src-zoo-Apple;
      }
    }
  }
  


(C) Æliens 20/2/2008

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.