From f02b7e574fd7b178d1f21d506b1a0ea450fc81ec Mon Sep 17 00:00:00 2001 From: DavidCastillo4 Date: Wed, 3 Jun 2020 15:23:52 -0500 Subject: [PATCH 1/5] completed RPS --- main.js | 30 +++++++++++++++++++++++++++--- test.js | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 test.js diff --git a/main.js b/main.js index 72f0f1a8..7063bf55 100644 --- a/main.js +++ b/main.js @@ -13,10 +13,31 @@ const rl = readline.createInterface({ // the function that will be called by the unit test below const rockPaperScissors = (hand1, hand2) => { + let Words = ['rock', 'paper', 'scissors']; + let i = Words.indexOf(hand1.toLowerCase()); + let ii = Words.indexOf(hand2.toLowerCase()); + let SumN = i + ii; + let Outcome='Hand two wins!' + , Winner = 'Hand one wins!' + , Tie = "It's a tie!"; - // Write code here - // Use the unit test to see what is expected - + if (i == ii) { + //Msg = 'Tie'; + Outcome = Tie; + } + else if (SumN == 1) { + //Msg = 'Paper covers Rock'; + if (i == 1) Outcome = Winner; + } + else if (SumN == 2) { + //Msg = 'Rock destroys Scissors'; + if (i == 0) Outcome = Winner; + } + else if (SumN == 3) { + //Msg = 'Scissors cut Paper'; + if (i == 2) Outcome = Winner; + }; + console.log(Outcome) } // the first function called in the program to get an input from the user @@ -60,3 +81,6 @@ if (typeof describe === 'function') { getPrompt(); } + + +//assert.equal(rockPaperScissors('rock', 'rock'), "It's a tie!") diff --git a/test.js b/test.js new file mode 100644 index 00000000..764087c5 --- /dev/null +++ b/test.js @@ -0,0 +1,39 @@ +let PlayGame = (hand1,hand2) => { + let Words = ['rock', 'paper', 'scissors']; + let i = Words.indexOf(hand1.toLowerCase()); + let ii = Words.indexOf(hand2.toLowerCase()); + let SumN = i + ii; + let Outcome='Hand two wins!' + , Winner = 'Hand one wins!' + , Tie = "It's a tie!"; + + if (i == ii) { + //Msg = 'Tie'; + Outcome = Tie; + } + else if (SumN == 1) { + //Msg = 'Paper covers Rock'; + if (i == 1) Outcome = Winner; + } + else if (SumN == 2) { + //Msg = 'Rock destroys Scissors'; + if (i == 0) Outcome = Winner; + } + else if (SumN == 3) { + //Msg = 'Scissors cut Paper'; + if (i == 2) Outcome = Winner; + }; + console.log(Outcome) +}; + + +PlayGame('rock','rock'); +PlayGame('rock','paper'); +PlayGame('rock','scissors'); + +PlayGame('paper','paper'); +PlayGame('paper','scissors'); + +PlayGame('scissors','scissors'); + + From 3d92f19debc963f4255199ade61d6cbc7276b66e Mon Sep 17 00:00:00 2001 From: DavidCastillo4 Date: Wed, 3 Jun 2020 15:30:04 -0500 Subject: [PATCH 2/5] deleted rps --- main.js | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/main.js b/main.js index 7063bf55..9b99674e 100644 --- a/main.js +++ b/main.js @@ -12,33 +12,7 @@ const rl = readline.createInterface({ }); // the function that will be called by the unit test below -const rockPaperScissors = (hand1, hand2) => { - let Words = ['rock', 'paper', 'scissors']; - let i = Words.indexOf(hand1.toLowerCase()); - let ii = Words.indexOf(hand2.toLowerCase()); - let SumN = i + ii; - let Outcome='Hand two wins!' - , Winner = 'Hand one wins!' - , Tie = "It's a tie!"; - if (i == ii) { - //Msg = 'Tie'; - Outcome = Tie; - } - else if (SumN == 1) { - //Msg = 'Paper covers Rock'; - if (i == 1) Outcome = Winner; - } - else if (SumN == 2) { - //Msg = 'Rock destroys Scissors'; - if (i == 0) Outcome = Winner; - } - else if (SumN == 3) { - //Msg = 'Scissors cut Paper'; - if (i == 2) Outcome = Winner; - }; - console.log(Outcome) -} // the first function called in the program to get an input from the user // to run the function use the command: node main.js From 5a899553116eb9fe3c9a33e6f3183219ac93e46f Mon Sep 17 00:00:00 2001 From: DavidCastillo4 Date: Wed, 3 Jun 2020 15:31:10 -0500 Subject: [PATCH 3/5] completed rps --- main.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/main.js b/main.js index 9b99674e..7063bf55 100644 --- a/main.js +++ b/main.js @@ -12,7 +12,33 @@ const rl = readline.createInterface({ }); // the function that will be called by the unit test below +const rockPaperScissors = (hand1, hand2) => { + let Words = ['rock', 'paper', 'scissors']; + let i = Words.indexOf(hand1.toLowerCase()); + let ii = Words.indexOf(hand2.toLowerCase()); + let SumN = i + ii; + let Outcome='Hand two wins!' + , Winner = 'Hand one wins!' + , Tie = "It's a tie!"; + if (i == ii) { + //Msg = 'Tie'; + Outcome = Tie; + } + else if (SumN == 1) { + //Msg = 'Paper covers Rock'; + if (i == 1) Outcome = Winner; + } + else if (SumN == 2) { + //Msg = 'Rock destroys Scissors'; + if (i == 0) Outcome = Winner; + } + else if (SumN == 3) { + //Msg = 'Scissors cut Paper'; + if (i == 2) Outcome = Winner; + }; + console.log(Outcome) +} // the first function called in the program to get an input from the user // to run the function use the command: node main.js From e4e7c1458000e0f77698143fde8312100d7be6c6 Mon Sep 17 00:00:00 2001 From: DavidCastillo4 Date: Thu, 4 Jun 2020 12:19:09 -0500 Subject: [PATCH 4/5] reset --- main.js | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/main.js b/main.js index 7063bf55..60ad64b5 100644 --- a/main.js +++ b/main.js @@ -12,33 +12,10 @@ const rl = readline.createInterface({ }); // the function that will be called by the unit test below -const rockPaperScissors = (hand1, hand2) => { - let Words = ['rock', 'paper', 'scissors']; - let i = Words.indexOf(hand1.toLowerCase()); - let ii = Words.indexOf(hand2.toLowerCase()); - let SumN = i + ii; - let Outcome='Hand two wins!' - , Winner = 'Hand one wins!' - , Tie = "It's a tie!"; - if (i == ii) { - //Msg = 'Tie'; - Outcome = Tie; - } - else if (SumN == 1) { - //Msg = 'Paper covers Rock'; - if (i == 1) Outcome = Winner; - } - else if (SumN == 2) { - //Msg = 'Rock destroys Scissors'; - if (i == 0) Outcome = Winner; - } - else if (SumN == 3) { - //Msg = 'Scissors cut Paper'; - if (i == 2) Outcome = Winner; - }; - console.log(Outcome) -} + + + // the first function called in the program to get an input from the user // to run the function use the command: node main.js From dc3a4fb61c3dcefa646e75739d430b60d1fa2434 Mon Sep 17 00:00:00 2001 From: DavidCastillo4 Date: Thu, 4 Jun 2020 12:20:49 -0500 Subject: [PATCH 5/5] completed rps --- main.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/main.js b/main.js index 60ad64b5..0dc224ce 100644 --- a/main.js +++ b/main.js @@ -13,7 +13,33 @@ const rl = readline.createInterface({ // the function that will be called by the unit test below +const rockPaperScissors = (hand1, hand2) => { + let Words = ['rock', 'paper', 'scissors']; + let i = Words.indexOf(hand1.toLowerCase()); + let ii = Words.indexOf(hand2.toLowerCase()); + let SumN = i + ii; + let Outcome='Hand two wins!' + , Winner = 'Hand one wins!' + , Tie = "It's a tie!"; + if (i == ii) { + //Msg = 'Tie'; + Outcome = Tie; + } + else if (SumN == 1) { + //Msg = 'Paper covers Rock'; + if (i == 1) Outcome = Winner; + } + else if (SumN == 2) { + //Msg = 'Rock destroys Scissors'; + if (i == 0) Outcome = Winner; + } + else if (SumN == 3) { + //Msg = 'Scissors cut Paper'; + if (i == 2) Outcome = Winner; + }; + console.log(Outcome) +}