-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
134 lines (113 loc) · 4.33 KB
/
Program.cs
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RockPaperScissors
{
class Program
{
static void Main(string[] args)
{
string inputPlayer, inputCPU;
int randomInt;
bool playAgain = true;
while (playAgain)
{
int scorePlayer = 0;
int scoreCPU = 0;
while(scorePlayer < 3 && scoreCPU < 3)
{
Console.WriteLine("Escolhe entre PEDRA, PAPEL ou TESOURA: ");
inputPlayer = Console.ReadLine();
inputPlayer = inputPlayer.ToUpper();
Random rnd = new Random();
randomInt = rnd.Next(1, 4);
switch (randomInt)
{
case 1:
inputCPU = "PEDRA";
Console.WriteLine("Computador escolhe PEDRA");
if (inputPlayer == "PEDRA")
{
Console.WriteLine("É um empate!\n\n");
}
else if (inputPlayer == "PAPEL")
{
Console.WriteLine("Tu ganhas!!\n\n");
scorePlayer++;
}
else if (inputPlayer == "TESOURA")
{
Console.WriteLine("CPU ganhou!\n\n");
scoreCPU++;
}
break;
case 2:
inputCPU = "PAPEL";
Console.WriteLine("Computador escolhe PAPEL");
if (inputPlayer == "PEDRA")
{
Console.WriteLine("CPU ganhou!\n\n");
scoreCPU++;
}
else if (inputPlayer == "PAPEL")
{
Console.WriteLine("É um empate!!\n\n");
}
else if (inputPlayer == "TESOURA")
{
Console.WriteLine("Ganhaste!\n\n");
scorePlayer++;
}
break;
case 3:
inputCPU = "TESOURA";
Console.WriteLine("Computador escolhe TESOURA");
if (inputPlayer == "PEDRA")
{
Console.WriteLine("Ganhaste!\n\n");
scorePlayer++;
}
else if (inputPlayer == "PAPEL")
{
Console.WriteLine("CPU ganhou!!\n\n");
scoreCPU++;
}
else if (inputPlayer == "TESOURA")
{
Console.WriteLine("É um empate!\n\n");
}
break;
default:
break;
}
Console.WriteLine("\n\nPONTOS:\tJOGADOR:\t{0}\tCPU:\t{1}", scorePlayer, scoreCPU);
}
if(scorePlayer == 3)
{
Console.WriteLine("GANHASTE!!!");
}
else if(scoreCPU == 3)
{
Console.WriteLine("CPU GANHOU!!!");
}
else
{
}
Console.WriteLine("Queres jogar outra vez?(s/n)");
string loop = Console.ReadLine();
if(loop == "s")
{
playAgain = true;
Console.Clear();
}
else if (loop == "n")
{
playAgain = false;
}
else { }
}
}
}
}