var Basketball = function(){
this.intro = '篮球盛行于美国'
}
Basketball.prototype = {
getMember: function(){
console.log("每个队伍需要5名队员")
},
getBallSize: function(){
console.log("篮球很大")
}
}
var Football = function(){
this.intro = '足球在世界范围内很流行'
}
Football.prototype = {
getMember:function(){
console.log("每个队伍需要11名队员")
},
getBallSize: function(){
console.log("足球很大")
}
}
var Tennis = function(){
this.intro = '每年有很多网球系列赛'
}
Football.prototype = {
getMember:function(){
console.log("每个队伍需要1名队员")
},
getBallSize: function(){
console.log("网球很小")
}
}
//运动工厂
var SportsFactory = function(name){
switch(name) {
case 'NBA':
return new Basketball();
case 'wordCup':
return new Football();
case 'FrenchOpen':
return new Tennis()
}
}
var footnall = SportsFactory('wordCup');
console.log(footnall)
console.log(footnall.intro)
console.log(footnall.getMember)
footnall.getBallSize()
var Car = function(){};
Car.prototype = {
getPrice:function(){
console.log("-0-0-")
// return new Error("抽象方法不能调用")
}
}
subClass.prototype = new Car() //继承父类Car
console