Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/Rock-paper-scissors/JavaScript/rock-paper-scissors.js
Normal file
25
Task/Rock-paper-scissors/JavaScript/rock-paper-scissors.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
const logic = {
|
||||
rock: { w: 'scissor', l: 'paper'},
|
||||
paper: {w:'rock', l:'scissor'},
|
||||
scissor: {w:'paper', l:'rock'},
|
||||
}
|
||||
|
||||
class Player {
|
||||
constructor(name){
|
||||
this.name = name;
|
||||
}
|
||||
setChoice(choice){
|
||||
this.choice = choice;
|
||||
}
|
||||
challengeOther(PlayerTwo){
|
||||
return logic[this.choice].w === PlayerTwo.choice;
|
||||
}
|
||||
}
|
||||
|
||||
const p1 = new Player('Chris');
|
||||
const p2 = new Player('John');
|
||||
|
||||
p1.setChoice('rock');
|
||||
p2.setChoice('scissor');
|
||||
|
||||
p1.challengeOther(p2); //true (Win)
|
||||
Loading…
Add table
Add a link
Reference in a new issue