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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ obj
.Trashes
ehthumbs.db
Thumbs.db
test/*
96 changes: 88 additions & 8 deletions RockPaperScissors/RockPaperScissors.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,104 @@
using System;
using System.Threading;

namespace RockPaperScissors
{
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();
Console.Clear(); // Clears the console prior to game start
Console.WriteLine("Welcome to Rock | Paper | Scissors!");
Console.WriteLine("When prompted, type either 'Rock', 'Paper', or 'Scissors' without single quotes.");
Thread.Sleep(1000);
Console.WriteLine("Type 'Quit' without single quotes to stop playing");
Console.WriteLine("Enter hand 1: ");
string hand1 = Console.ReadLine();
Console.Clear();

// If the user enters the word quit, terminates the program and clears the console
while (hand1.ToUpper() != "QUIT")
{
// Random number generator for computer turn that is then assigned
Random randNum = new Random();
string hand2 = Convert.ToString(randNum.Next(1, 4));

// Calls the method that checks who the winner is
CompareHands(hand1, hand2);

Thread.Sleep(500);

Console.WriteLine("Type either 'Rock', 'Paper', or 'Scissors' without single quotes to play again!");
Console.WriteLine("Type 'Quit' without single quotes to stop playing");
hand1 = Console.ReadLine();
Console.Clear();

}

Console.Clear();
}

public static string CompareHands(string hand1, string hand2)
{
// Your code here
if (hand2 == "1")
{
hand2 = "Rock";
}
else if (hand2 == "2")
{
hand2 = "Paper";
}
else
{
hand2 = "Scissors";
}

if (hand1.ToUpper() == hand2.ToUpper())
{
Console.WriteLine(hand1 + ' ' + hand2);
Console.WriteLine("It's a tie!");
}
else if (hand1.ToUpper() == "ROCK")
{
if (hand2.ToUpper() == "PAPER")
{
Console.WriteLine(hand1 + ' ' + hand2);
Console.WriteLine("Computer wins!");
}
else if (hand2.ToUpper() == "SCISSORS")
{
Console.WriteLine(hand1 + ' ' + hand2);
Console.WriteLine("Player wins!");
}
}
else if (hand1.ToUpper() == "PAPER")
{
if (hand2.ToUpper() == "ROCK")
{
Console.WriteLine(hand1 + ' ' + hand2);
Console.WriteLine("Player wins!");
}
else if (hand2.ToUpper() == "SCISSORS")
{
Console.WriteLine(hand1 + ' ' + hand2);
Console.WriteLine("Computer wins!");
}
}
else if (hand1.ToUpper() == "SCISSORS")
{
if (hand2.ToUpper() == "ROCK")
{
Console.WriteLine(hand1 + ' ' + hand2);
Console.WriteLine("Computer wins!");
}
else if (hand2.ToUpper() == "PAPER")
{
Console.WriteLine(hand1 + ' ' + hand2);
Console.WriteLine("Player wins!");
}
}

return hand1 + ' ' + hand2;
}
}
Expand Down
200 changes: 200 additions & 0 deletions TextGame/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
using System;
using System.Threading;

namespace TextAdventure
{
class Program
{
static void Main(string[] args)
{
int stick = 0;
int complete;
Random randNum = new Random();
String playAgain;
Boolean alive = true;

// If alive == true, continue to run. Starts as true
while (alive)
{
Console.Clear(); // Clears the console
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Console.WriteLine("Welcome to the cavern of secrets!");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

Thread.Sleep(3000); // Pauses the program for 3 seconds

// Asks the user if they want to take a stick for a weapon
Console.WriteLine("You enter a dark cavern out of curiosity. It is dark and you can only make out a small stick on the floor.");
Console.WriteLine("Do you take it? [Y/N]");
String ch1 = Console.ReadLine();
Console.Clear();

if (ch1.ToUpper() == "Y" || ch1.ToUpper() == "YES")
{
// If the user said yes, increments stick value to 1
Console.WriteLine("You take the stick!");
Thread.Sleep(2000);
stick = 1;
}
else
{
// If user doesn't take a stick, update to 0
Console.WriteLine("You did not take the stick.");
Thread.Sleep(2000);
stick = 0;
}

// Asks the user if the want to enter the cave
Console.WriteLine("As you proceed further into the cave, you see a small glowing object...");
Console.WriteLine("Do you approach the object? [Y/N]");
String ch2 = Console.ReadLine();
Console.Clear();

if (ch2.ToUpper() == "Y" || ch2.ToUpper() == "YES")
{
// If the user answers yes, they enter the cave.
// The text displays a series of lines at set intervals
Console.WriteLine("You approach the object...");
Thread.Sleep(2000);
Console.WriteLine("As you draw closer, you begin to make out the object as an eye!");
Thread.Sleep(1000);
Console.WriteLine("The eye belongs to a giant spider!");
Console.WriteLine("Do you try to fight it? [Y/N]"); // Asks the user if they want to fight the spider
String ch3 = Console.ReadLine();
Console.Clear();

if (ch3.ToUpper() == "Y" || ch3.ToUpper() == "YES")
{
if (stick == 1)
{
// Series of text to show the battle
Console.WriteLine("You only have a stick to fight with.");
Console.WriteLine("You quickly jab the spider in it's eye and gain an advantage");
Thread.Sleep(2000);
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Console.WriteLine(" Fighting... ");
Console.WriteLine(" YOU MUST HIT ABOVE A 5 TO KILL THE SPIDER ");
Console.WriteLine("IF THE SPIDER HITS HIGHER THAN YOU, YOU WILL DIE");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Thread.Sleep(2000);
// generates random numbers to indicate the damage done by you and the enemy
int fdmg1 = randNum.Next(1, 10);
int edmg1 = randNum.Next(1, 5);
Console.WriteLine("You hit the spider for {0}", fdmg1);
Console.WriteLine("The spider hits you for {0}", edmg1);
Thread.Sleep(2000);

if (edmg1 > fdmg1) // If the enemy damage is greater than user damage
{
Console.WriteLine("The spider has dealt more damage than you!");
complete = 0;
}
else if (fdmg1 < 5) // If the enemy damage is less than user damage but user isn't greater than 5
{
Console.WriteLine("You didn't do enough damage to kill the spider, but you manage to escape!");
complete = 1;
}
else // If user damage is greater is greater than 5
{
Console.WriteLine("You killed the spider!");
complete = 1;
}
}
else
{
// If user doesn't have a stick
Console.WriteLine("You don't have anything to fight with!");
Thread.Sleep(2000);
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Console.WriteLine(" Fighting... ");
Console.WriteLine(" YOU MUST HIT ABOVE A 5 TO KILL THE SPIDER ");
Console.WriteLine("IF THE SPIDER HITS HIGHER THAN YOU, YOU WILL DIE");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Thread.Sleep(2000);
// generates random numbers to indicate the damage done by you and the enemy
int fdmg1 = randNum.Next(1, 8);
int edmg1 = randNum.Next(1, 5);
Console.WriteLine("You hit the spider for {0}", fdmg1);
Console.WriteLine("The spider hits you for {0}", edmg1);
Thread.Sleep(2000);

if (edmg1 > fdmg1) // If the enemy damage is greater than user damage
{
Console.WriteLine("The spider has dealt more damage than you!");
complete = 0;
}
else if (fdmg1 < 5) // If the enemy damage is less than user damage but user isn't greater than 5
{
Console.WriteLine("You didn't do enough damage to kill the spider, but you manage to escape!");
complete = 1;
}
else // If user damage is greater is greater than 5
{
Console.WriteLine("You killed the spider!");
complete = 1;
}
}
}
else
{
// Runs if the user chooses not to fight
Console.WriteLine("You choose not to fight the spider.");
Thread.Sleep(1000);
Console.WriteLine("As you turn away, it ambushes you and impales you with it's fangs!");
complete = 0;
}
}
else
{
// Runs if the user chooses not to enter the cave
Console.WriteLine("You turn away from the glowing object, and attempt to leave the cave...");
Thread.Sleep(1000);
Console.WriteLine("But something won't let you...");
Thread.Sleep(2000);
complete = 0;
}

// Allows for a rerun of the program
// If complete is '1', then notes success in the game
// If complete is '0', then failure
// Either route gives player an option to play again
if (complete == 1)
{
// Runs if you lived
Console.WriteLine("You managed to escape the cavern alive! Would you like to play again? [Y/N]");
playAgain = Console.ReadLine();

if(playAgain.ToUpper() == "Y" || playAgain.ToUpper() == "YES")
{
Console.Clear();
}
else
{
Console.WriteLine("Thanks for playing!");
alive = false;
Thread.Sleep(1500);
Console.Clear();
}
}
else
{
// Runs if you are dead
Console.WriteLine("You have died! Would you like to play again? [Y/N]");
playAgain = Console.ReadLine();

if(playAgain.ToUpper() == "Y" || playAgain.ToUpper() == "YES")
{
Console.Clear();
}
else
{
Console.WriteLine("Thanks for playing!");
alive = false;
Thread.Sleep(1500);
Console.Clear();
}
}
}
}
}
}
8 changes: 8 additions & 0 deletions TextGame/TextAdventure.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

</Project>
58 changes: 58 additions & 0 deletions week1-practice1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Threading;

namespace week1_practice1
{
class Program
{
static void Main(string[] args)
{
int numA;
int numB;
int total;

Console.WriteLine("Enter an integer value for 'a'");
numA = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter an integer value for 'b'");
numB = Convert.ToInt32(Console.ReadLine());
total = numA + numB;
Console.WriteLine("{0} plus {1} equals {2}", numA, numB, total);
Console.ReadKey();
Console.Clear();

double yards = 0.0d;
double inches = 0.0d;

Console.WriteLine("To convert yards, please enter the number of yards");
yards = Convert.ToDouble(Console.ReadLine());
inches = yards * 12;
Console.WriteLine("There are {0} inches in {1} yard(s)", inches, yards);
Console.ReadKey();
Console.Clear();

Boolean people = true;
Boolean f = false;

decimal num = 0.0M;
decimal prod = 0.0M;

Console.WriteLine("Enter a number to be multiplied by iteself");
num = Convert.ToDecimal(Console.ReadLine());
prod = num * num;
Console.WriteLine("The product of {0} multiplied by {0} is {1}", num, prod);
Console.Clear();

String firstName = "Wes";
String lastName = "Garbee";
int age = 34;
String job = "Sales";
String favoriteBand = "Alpha Rev";
String favoriteSportsTeam = "Astros";

Console.WriteLine("Hi! My name is {0} {1} and I am {2} years old.", firstName, lastName, age);
Console.WriteLine("My job is {0}. My favorite band is {1}. My favorite sports team are the {2}.", job, favoriteBand, favoriteSportsTeam);
Console.WriteLine("Press any key to end...");
Console.ReadKey();
}
}
}
9 changes: 9 additions & 0 deletions week1-practice1/week1-practice1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RootNamespace>week1_practice1</RootNamespace>
</PropertyGroup>

</Project>
Loading