Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions PigLatin/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/PigLatin.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
,]
}
15 changes: 15 additions & 0 deletions PigLatin/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/PigLatin.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
28 changes: 28 additions & 0 deletions RockPaperScissors/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/RockPaperScissors.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
,]
}
15 changes: 15 additions & 0 deletions RockPaperScissors/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/RockPaperScissors.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
137 changes: 123 additions & 14 deletions RockPaperScissors/RockPaperScissors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,129 @@ class Program
{
public static void Main()
{
Console.WriteLine("Enter hand 1:");
string hand1 = Console.ReadLine().ToLower();
Console.WriteLine("Enter hand 2:");
string hand2 = Console.ReadLine().ToLower();
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;
string player1Hand = "";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you have multiple methods, but some comments before each method explaining what the method does would have been nice.

int player1Score = 0;
string comHand = "";
int comScore = 0;
int ties = 0;
string[] rps = new string[] {"rock", "paper", "scissors"};

PlayerTurn();
ComTurn();
WinCheck();
Scoreboard();
PlayAgain();

void PlayerTurn(){
Console.WriteLine("Please type 1 for Rock, 2 for Paper, or 3 for Scissors and press the Enter key: ");
// int player1Choice = Convert.ToInt32(Console.ReadLine()) - 1;
string player1Choice = Console.ReadLine();
System.Threading.Thread.Sleep(500);
if ((player1Choice == "1") || (player1Choice == "2") || (player1Choice == "3"))
{
player1Hand = rps[Convert.ToInt32(player1Choice) - 1];
Console.WriteLine("You chose " + player1Hand +".");
System.Threading.Thread.Sleep(500);
}
else
{
Console.WriteLine("Your choice is invalid. Choose again.");
System.Threading.Thread.Sleep(500);
PlayerTurn();
}
}

void ComTurn(){
Random rnd = new Random();
int roll = rnd.Next(0, 3);
comHand = rps[roll];
Console.WriteLine("The Computer Mastermind chose " + comHand + ".");
System.Threading.Thread.Sleep(500);
}

void WinCheck(){

if (player1Hand == comHand){
Console.WriteLine("That's a tie!");
ties ++;
System.Threading.Thread.Sleep(500);
}
else if (player1Hand == "rock" && comHand == "paper"){
Console.WriteLine("Paper beats rock! You lose!");
comScore ++;
System.Threading.Thread.Sleep(500);
}
else if (player1Hand == "rock" && comHand == "scissors"){
Console.WriteLine("Rock beats scissors! You win!");
player1Score ++;
System.Threading.Thread.Sleep(500);
}
else if (player1Hand == "scissors" && comHand == "paper"){
Console.WriteLine("Scissors beats paper! You win!");
player1Score ++;
System.Threading.Thread.Sleep(500);
}
else if (player1Hand == "scissors" && comHand == "rock"){
Console.WriteLine("Rock beats scissors! You lose!");
comScore ++;
System.Threading.Thread.Sleep(500);
}
else if (player1Hand == "paper" && comHand == "rock"){
Console.WriteLine("Paper beats rock! You win!");
player1Score ++;
System.Threading.Thread.Sleep(500);
}
else if (player1Hand == "paper" && comHand == "scissors"){
Console.WriteLine("Scissors beats paper! You lose!");
comScore ++;
System.Threading.Thread.Sleep(500);
}
}

// void WinCheckSmall(){
// if (player1Hand == comHand){
// Console.WriteLine("That's a tie!");
// ties ++;
// }
// else if (player1Hand == "rock" && comHand == "paper") || (player1Hand == "scissors" && comHand == "rock") {
// Console.WriteLine("Paper beats rock! You lose!");
// comScore ++;
// }
// }

void Scoreboard(){
// Console.WriteLine("CURRENT SCORE: \n PLAYER 1: " + player1Score + "\nCOMPUTER MASTERMIND SCORE: " + comScore);
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Console.WriteLine(" CURRENT SCORE: ");
Console.WriteLine(" PLAYER 1: " + player1Score);
Console.WriteLine(" COMPUTER MASTERMIND: " + comScore);
Console.WriteLine(" TIES: " + ties);
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.Threading.Thread.Sleep(500);
}

void PlayAgain() {
string[] yes = { Convert.ToString('y'), Convert.ToString('Y'), "yes", "Yes", "YES"};
Console.WriteLine("Do you want to try again? [y/n]");
for (int i = 0; i < yes.Length; i++)
{
string choice = Console.ReadLine();
if (choice == yes[i])
{
Console.Clear();
PlayerTurn();
ComTurn();
WinCheck();
Scoreboard();
PlayAgain();
}
else
{
Console.WriteLine("Bye! Thanks for playing!");
Environment.Exit(0);
}
}
}
}
}
}
28 changes: 28 additions & 0 deletions TicTacToe/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TicTacToe should not be in this branch.

// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/TicTacToe.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
,]
}
15 changes: 15 additions & 0 deletions TicTacToe/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/TicTacToe.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
Loading