classicalinheritance.js

来自「买书附带的光盘资料Foundations_Of_Ajax中文版教程及源代码。 」· JavaScript 代码 · 共 50 行

JS
50
字号
function Vehicle() {    var wheelCount = 4;    var curbWeightInPounds = 4000;    this.getWheelCount = function() {        return wheelCount;    }    this.setWheelCount = function(count) {        wheelCount = count;    }    this.getCurbWeightInPounds = function() {        return curbWeightInPounds;    }    this.setCurbWeightInPounds = function(weight) {        curbWeightInPounds = weight;    }    this.refuel = function() {        return "Refueling Vehicle with regular 87 octane gasoline";    }    this.mainTasks = function() {        return "Driving to work, school, and the grocery store";    }}function SportsCar() {    this.refuel = function() {        return "Refueling SportsCar with premium 94 octane gasoline";    }    this.mainTasks = function() {        return "Spirited driving, looking good, driving to the beach";    }}function CementTruck() {    this.refuel = function() {        return "Refueling CementTruck with diesel fuel";    }    this.mainTasks = function() {        return "Arrive at construction site, extend boom, deliver cement";    }}

⌨️ 快捷键说明

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