-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathRockPaperScissors.cs
More file actions
60 lines (46 loc) · 1.53 KB
/
RockPaperScissors.cs
File metadata and controls
60 lines (46 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
namespace RockPaperScissors
{
public class Program
{
public static void Main()
{
int scoreOne = 0;
int scoreTwo = 0;
Console.WriteLine("Enter hand 1:");
string hand1 = Console.ReadLine().ToLower();
Console.WriteLine("Enter hand 2:");
string hand2 = Console.ReadLine().ToLower();
string winner = (CompareHands(hand1, hand2));
string[] winnerSep = winner.Split("*");
string winnerText = winnerSep[0];
int winnerAdd = Convert.ToInt32(winnerText);
if (winnerAdd == 1){
scoreOne++;
}
else if (winnerAdd == 2){
scoreTwo++;
}
Console.WriteLine(winnerText);
Console.WriteLine("The score is " + scoreOne + "to " + scoreTwo);
// leave this command at the end so your program does not close automatically
Console.ReadLine();
}
public static string CompareHands(string hand1, string hand2)
{
if (hand1==hand2){
return "It's a tie.";}
else if (hand1 == "rock" && hand2 == "scissors"){
return "Hand 1 Wins!!!*1";
}
else if (hand1 == "scissors" && hand2 == "paper"){
return "Hand 1 Wins!!!*1";
}
else if (hand1 == "paper" && hand2 == "rock"){
return "Hand 1 Wins!!!*1";
}
else {
return "Hand 1 Loses!!!*2";}
}
}
}