From 0468f4a1de2139fa141210fcc62c4e62fa435b75 Mon Sep 17 00:00:00 2001 From: Jason Connolly Date: Thu, 19 Jul 2018 12:11:45 -0500 Subject: [PATCH 01/10] RockPaperScissors --- RockPaperScissors/RockPaperScissors.cs | 50 ++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index 470ae756..f52f9342 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -5,21 +5,59 @@ namespace RockPaperScissors class Program { public static void Main() + { - Console.WriteLine("Enter hand 1:"); + + Console.WriteLine("Rock, Paper or Sissors?:"); string hand1 = Console.ReadLine().ToLower(); - Console.WriteLine("Enter hand 2:"); - string hand2 = Console.ReadLine().ToLower(); + + string hand2 = null; + Random rnd = new Random(); + int rps = rnd.Next(0,2); + if (rps == 0) + { + hand2 = "rock"; + } + else if (rps == 1) + { + hand2 = "paper"; + } + else if (rps == 2) + { + hand2 = "sissors"; + } + + + Console.WriteLine("Computer played:"); Console.WriteLine(CompareHands(hand1, hand2)); // leave this command at the end so your program does not close automatically - Console.ReadLine(); + } public static string CompareHands(string hand1, string hand2) { - // Your code here - return hand1 + ' ' + hand2; + /*Random rnd = new Random(); + int rock = rnd.Next(0,2); + int paper = rnd.Next(0,2); + int sissors = rnd.Next(0,2);*/ + + string win = null; + if (hand1 == hand2) + { + win = "TIE!"; + } + else if (hand1 == "paper" && hand2 == "rock" || hand1 == "rock" && hand2 == "sissors" || hand1 == "sissors" && hand2 == "paper") + { + win = "You Win!"; + } + + else if (hand1 == "rock" && hand2 == "paper" || hand1 == "sissors" && hand2 == "rock" || hand1 == "paper" && hand2 == "sissors") + { + win = "Computer Wins!"; + } + + return win; } } } From 1a82e9f7646e52de3ccf8ba73de7766065a025c9 Mon Sep 17 00:00:00 2001 From: Jason Connolly Date: Thu, 19 Jul 2018 12:13:33 -0500 Subject: [PATCH 02/10] RockPaperScissors --- RockPaperScissors/RockPaperScissors.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index f52f9342..a283cbce 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -8,9 +8,9 @@ public static void Main() { - Console.WriteLine("Rock, Paper or Sissors?:"); + Console.WriteLine("Rock, Paper or Scissors?:"); string hand1 = Console.ReadLine().ToLower(); - + string hand2 = null; Random rnd = new Random(); int rps = rnd.Next(0,2); @@ -24,7 +24,7 @@ public static void Main() } else if (rps == 2) { - hand2 = "sissors"; + hand2 = "scissors"; } @@ -40,19 +40,19 @@ public static string CompareHands(string hand1, string hand2) /*Random rnd = new Random(); int rock = rnd.Next(0,2); int paper = rnd.Next(0,2); - int sissors = rnd.Next(0,2);*/ + int scissors = rnd.Next(0,2);*/ string win = null; if (hand1 == hand2) { win = "TIE!"; } - else if (hand1 == "paper" && hand2 == "rock" || hand1 == "rock" && hand2 == "sissors" || hand1 == "sissors" && hand2 == "paper") + else if (hand1 == "paper" && hand2 == "rock" || hand1 == "rock" && hand2 == "scissors" || hand1 == "scissors" && hand2 == "paper") { win = "You Win!"; } - else if (hand1 == "rock" && hand2 == "paper" || hand1 == "sissors" && hand2 == "rock" || hand1 == "paper" && hand2 == "sissors") + else if (hand1 == "rock" && hand2 == "paper" || hand1 == "scissors" && hand2 == "rock" || hand1 == "paper" && hand2 == "scissors") { win = "Computer Wins!"; } From 71f6d17a27af205c9f9630fde0f9be060bdab2a5 Mon Sep 17 00:00:00 2001 From: Jason Connolly Date: Thu, 19 Jul 2018 12:59:59 -0500 Subject: [PATCH 03/10] RockPaperScissors --- RockPaperScissors/RockPaperScissors.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index a283cbce..9b048aed 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -20,7 +20,7 @@ public static void Main() } else if (rps == 1) { - hand2 = "paper"; + hand2 = "paper"; } else if (rps == 2) { @@ -29,18 +29,13 @@ public static void Main() Console.WriteLine("Computer played:"); + Console.WriteLine(hand2.ToString()); Console.WriteLine(CompareHands(hand1, hand2)); - - // leave this command at the end so your program does not close automatically } public static string CompareHands(string hand1, string hand2) - { - /*Random rnd = new Random(); - int rock = rnd.Next(0,2); - int paper = rnd.Next(0,2); - int scissors = rnd.Next(0,2);*/ + { string win = null; if (hand1 == hand2) From bfecd20d6380aee0efdd7c019d44b7a850958246 Mon Sep 17 00:00:00 2001 From: Jason Connolly Date: Thu, 19 Jul 2018 13:18:31 -0500 Subject: [PATCH 04/10] RockPaperScissors --- RockPaperScissors/RockPaperScissors.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index 9b048aed..15f82d1e 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -14,6 +14,7 @@ public static void Main() string hand2 = null; Random rnd = new Random(); int rps = rnd.Next(0,2); + if (rps == 0) { hand2 = "rock"; From 295a9ddeb79b994978375b4469dc57c31b985470 Mon Sep 17 00:00:00 2001 From: Jason Connolly Date: Mon, 23 Jul 2018 11:52:30 -0500 Subject: [PATCH 05/10] RockPaperScissors --- RockPaperScissors/RockPaperScissors.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index 15f82d1e..b4db9053 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -54,6 +54,7 @@ public static string CompareHands(string hand1, string hand2) } return win; + } } -} +} \ No newline at end of file From ed64b0468e67cc3039dc6c9dc21cb3ae2b91ef06 Mon Sep 17 00:00:00 2001 From: Jason Connolly Date: Mon, 23 Jul 2018 13:01:48 -0500 Subject: [PATCH 06/10] RockPaperScissors --- RockPaperScissors/RockPaperScissors.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index b4db9053..c4ffcc73 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -13,8 +13,9 @@ public static void Main() string hand2 = null; Random rnd = new Random(); - int rps = rnd.Next(0,2); + int rps = rnd.Next(0,2); //hand2 is played by computer + //defines hand2 response to hand1 entry if (rps == 0) { hand2 = "rock"; @@ -37,7 +38,7 @@ public static void Main() public static string CompareHands(string hand1, string hand2) { - + //all possibilities for palys, with win answer string win = null; if (hand1 == hand2) { From cb8093c9b09a64ef960b01d531afbc2ca3af2179 Mon Sep 17 00:00:00 2001 From: Jason Connolly Date: Mon, 23 Jul 2018 13:02:51 -0500 Subject: [PATCH 07/10] RockPaperScissors --- RockPaperScissors/RockPaperScissors.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index c4ffcc73..92f3a06f 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -13,7 +13,7 @@ public static void Main() string hand2 = null; Random rnd = new Random(); - int rps = rnd.Next(0,2); //hand2 is played by computer + int rps = rnd.Next(0,2); //hand2 is played by computer random //defines hand2 response to hand1 entry if (rps == 0) From e99e038aa49658618764e67288bb50bbfe4cd97f Mon Sep 17 00:00:00 2001 From: Jason Connolly Date: Mon, 23 Jul 2018 13:17:22 -0500 Subject: [PATCH 08/10] RockPaperScissors --- RockPaperScissors/RockPaperScissors.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index 92f3a06f..0b55cb28 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -7,8 +7,8 @@ class Program public static void Main() { - - Console.WriteLine("Rock, Paper or Scissors?:"); + Console.WriteLine("Hello []"); + Console.WriteLine("Enter Rock, Paper or Scissors?"); string hand1 = Console.ReadLine().ToLower(); string hand2 = null; From 021352ceaec53b1bef3406b4891962c335e8ddc5 Mon Sep 17 00:00:00 2001 From: Jason Connolly Date: Mon, 23 Jul 2018 15:03:43 -0500 Subject: [PATCH 09/10] RockPaperScissors --- RockPaperScissors/RockPaperScissors.cs | 43 +++++++++++++++++++++----- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index 0b55cb28..ae477402 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -2,13 +2,16 @@ namespace RockPaperScissors { - class Program + class Program { + public static int score1 = 0; + public static int score2 = 0; //default values + public static void Main() { - Console.WriteLine("Hello []"); - Console.WriteLine("Enter Rock, Paper or Scissors?"); + Console.WriteLine("Hello"); + Console.WriteLine("Enter Rock, Paper or Scissors"); string hand1 = Console.ReadLine().ToLower(); string hand2 = null; @@ -30,10 +33,21 @@ public static void Main() } - Console.WriteLine("Computer played:"); - Console.WriteLine(hand2.ToString()); + Console.WriteLine(CompareHands(hand1, hand2)); - + Console.WriteLine("Your Score:" + score1); + Console.WriteLine("Computer Score:" + score2); + Console.WriteLine("Play again Yes or No"); + string hand = Console.ReadLine().ToLower(); + if (hand=="yes") + { + Main(); //recurssion + } + else + { + Console.Read(); + } + } public static string CompareHands(string hand1, string hand2) @@ -42,20 +56,35 @@ public static string CompareHands(string hand1, string hand2) string win = null; if (hand1 == hand2) { - win = "TIE!"; + Console.WriteLine("Computer played:"); + Console.WriteLine(hand2.ToString()); + win = "TIE!"; } else if (hand1 == "paper" && hand2 == "rock" || hand1 == "rock" && hand2 == "scissors" || hand1 == "scissors" && hand2 == "paper") { + Console.WriteLine("Computer played:"); + Console.WriteLine(hand2.ToString()); + score1++; win = "You Win!"; } else if (hand1 == "rock" && hand2 == "paper" || hand1 == "scissors" && hand2 == "rock" || hand1 == "paper" && hand2 == "scissors") { + Console.WriteLine("Computer played:"); + Console.WriteLine(hand2.ToString()); + score2++; win = "Computer Wins!"; } + else + { + //returns line without computer play + Console.WriteLine("Invalid Selection"); + Main(); + } return win; + } } } \ No newline at end of file From 25d120b314cb026ee4eac4141c01e39b50121046 Mon Sep 17 00:00:00 2001 From: Jason Connolly Date: Tue, 14 Aug 2018 13:51:00 -0500 Subject: [PATCH 10/10] RockPaperScissors --- RockPaperScissors/RockPaperScissors.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index ae477402..54f21def 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -7,16 +7,31 @@ class Program public static int score1 = 0; public static int score2 = 0; //default values + public String getUserHand(){ + String input = Console.ReadLine().ToLower(); + if(input != "rock" && input != "scissors" && input != "paper") { + throw new Exception("Bad hand..."); + } + return input; + } + public static void Main() { Console.WriteLine("Hello"); Console.WriteLine("Enter Rock, Paper or Scissors"); - string hand1 = Console.ReadLine().ToLower(); + //string hand1 = Console.ReadLine().ToLower(); + string hand1 = null; + try{ + hand1 = getUserHand(); + } catch(Exception){ + Main(); + } + string hand2 = null; Random rnd = new Random(); - int rps = rnd.Next(0,2); //hand2 is played by computer random + int rps = rnd.Next(0,3); //hand2 is played by computer random //defines hand2 response to hand1 entry if (rps == 0)