-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
51 lines (47 loc) · 1.99 KB
/
Program.cs
File metadata and controls
51 lines (47 loc) · 1.99 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
Console.WriteLine(" ***STARTING GAME***\n***ROCK PAPER SCISSORS***");
HumanPlayer player_human = new HumanPlayer(5);
ComputerPlayer player_computer = new ComputerPlayer();
while (player_human.GetPoints() > 0)
{
Console.WriteLine($"You have {player_human.GetPoints()} points.");
string human_move = player_human.HumanDecision();
string computer_move = player_computer.ComputerDecision();
if ((human_move == "rock" && computer_move == "scissors") || (human_move == "scissors" && computer_move == "paper") || (human_move == "paper" && computer_move == "rock"))
{
player_human.WinRound();
Console.WriteLine($"Your Decision: {human_move}\nComputer Decision: {computer_move}\nYou Win!");
}
else if ((computer_move == "rock" && human_move == "scissors") || (computer_move == "scissors" && human_move == "paper") || (computer_move == "paper" && human_move == "rock") || (computer_move == "lava rocks!"))
{
player_human.LoseRound();
Console.WriteLine($"Your Decision: {human_move}\nComputer Decision: {computer_move}\nYou Lose!");
}
else
{
Console.WriteLine($"Your Decision: {human_move}\nComputer Decision: {computer_move}\nIt's a tie!");
}
if (player_human.GetPoints() > 0)
{
Console.WriteLine("Play again? Input y to continue, or n to exit.");
string playAgain = Console.ReadLine() ?? string.Empty;
if (playAgain.ToLower() == "n")
{
Console.WriteLine($"Game Over!\nThanks for playing!\nYour High Score: {player_human.GetPoints()}");
break;
}
else if (playAgain.ToLower() == "y")
{
Console.WriteLine("Starting next round...");
continue;
}
else
{
Console.WriteLine($"Invalid input...\nEnding Game.\nYour total points: {player_human.GetPoints()}");
break;
}
}
else
{
Console.WriteLine("Game Over!\nSorry you lost all your points...\nThanks for playing!");
}
}