⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apple.as

📁 精通Actionscript 3.0 书籍源代码 非常实用
💻 AS
字号:
package zoo {  // The Apple class represents one of the types of food a pet can eat  public class Apple extends Food {    // The amount of calories in an Apple object, if no specific     // amount is indicated    private static var DEFAULT_CALORIES:int = 100;    // Tracks whether an Apple object has a worm    private var wormInApple:Boolean;      // Constructor    public function Apple (initialCalories:int = 0) {      // If no valid calorie amount is specified...      if (initialCalories <= 0) {        // ...give this Apple object the default amount        initialCalories = Apple.DEFAULT_CALORIES;      }      // Invoke the Food class constructor      super(initialCalories);      // Randomly determine whether this Apple object as a worm (50% chance)      wormInApple = Math.random() >= .5;            // Give this food item a name      setName("Apple");    }    // Returns a Boolean indicating whether the Apple object has a worm    public function hasWorm ():Boolean {      return wormInApple;    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -