apple.as
来自「精通Actionscript 3.0 书籍源代码 非常实用」· AS 代码 · 共 33 行
AS
33 行
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 + =
减小字号Ctrl + -
显示快捷键?