Uncaught SyntaxError: Unexpected identifier求解救啊
Object.prototype.extends=function(parents,action){for(varpropinparents){this.prototyp...
Object.prototype.extends = function(parents,action){ for (var prop in parents) { this.prototype[prop]=parents.prototype[prop] } for (var prop in action) { this.prototype[prop]=action[prop] }}function Player (name){ this.name = name; this.point = -1;}Player.prototype={ guess:function(){ console.error('此方法是chouxiang'); }}
function NormalPlayer (name){ this.name = name; this.point = -1;}NormalPlayer.extends(Player,{ guess:function(){ this.point = window.prompt('请输入123,1石头2剪刀3布'); }})
function ComPlayer (name){ this.name = name; this.point= -1;}ComPlayer.extends(Player,{ guess:function(){ this.point = parseInt(Math.random()*100)%3+1; }})
function GuessSystem (player1,player2){ this.p1 = player1; this.p2 = player2;}GuessSystem.prototype = { play:function (){ var res; this.p1.guess(); this.p2.guess(); res = biJiao(this.p1.point,this.p2.point); this.show(res); } biJiao:function(play1,play2){ var res = play1-play2; return res; } show: function (bijiao){ switch (bijiao){ case -1||1: console.log('You Win!'); break; case -2||2: console.log('You Lose!'); break; case 0: console.log('Draw!!!'); break; default: console.log('程序错误!!'); break; } }} 展开
function NormalPlayer (name){ this.name = name; this.point = -1;}NormalPlayer.extends(Player,{ guess:function(){ this.point = window.prompt('请输入123,1石头2剪刀3布'); }})
function ComPlayer (name){ this.name = name; this.point= -1;}ComPlayer.extends(Player,{ guess:function(){ this.point = parseInt(Math.random()*100)%3+1; }})
function GuessSystem (player1,player2){ this.p1 = player1; this.p2 = player2;}GuessSystem.prototype = { play:function (){ var res; this.p1.guess(); this.p2.guess(); res = biJiao(this.p1.point,this.p2.point); this.show(res); } biJiao:function(play1,play2){ var res = play1-play2; return res; } show: function (bijiao){ switch (bijiao){ case -1||1: console.log('You Win!'); break; case -2||2: console.log('You Lose!'); break; case 0: console.log('Draw!!!'); break; default: console.log('程序错误!!'); break; } }} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询