fish.js

来自「原名JSPackager」· JavaScript 代码 · 共 27 行

JS
27
字号
/**
 * 鱼类
 * @constructor
 */
function Fish(){
}
/**
 * 鱼类也是动物
 */
Fish.prototype = new Animal();
/**
 * 进食,有误食鱼饵的危险
 */
Fish.prototype.eat = function(food){
  if(food instanceof Bait){
    //误食鱼饵,被抓
    food.owner.acquisition = this;
  }else{
    //do eating
  }
}
/**
 * 定义Fish对象作为String操作的时候的值
 */
Fish.prototype.toString = function(){
  return "Fish instance";
}

⌨️ 快捷键说明

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