diff --git a/.gitignore b/.gitignore index dfb074ab..2d9cbb35 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ obj .Trashes ehthumbs.db Thumbs.db +test/* \ No newline at end of file diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index 470ae756..1634fec3 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; namespace RockPaperScissors { @@ -6,19 +7,98 @@ 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; } } diff --git a/TextGame/Program.cs b/TextGame/Program.cs new file mode 100644 index 00000000..979d00ac --- /dev/null +++ b/TextGame/Program.cs @@ -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(); + } + } + } + } + } +} diff --git a/TextGame/TextAdventure.csproj b/TextGame/TextAdventure.csproj new file mode 100644 index 00000000..23df6047 --- /dev/null +++ b/TextGame/TextAdventure.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/week1-practice1/Program.cs b/week1-practice1/Program.cs new file mode 100644 index 00000000..dda34e2c --- /dev/null +++ b/week1-practice1/Program.cs @@ -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(); + } + } +} diff --git a/week1-practice1/week1-practice1.csproj b/week1-practice1/week1-practice1.csproj new file mode 100644 index 00000000..d8991fbf --- /dev/null +++ b/week1-practice1/week1-practice1.csproj @@ -0,0 +1,9 @@ + + + + Exe + netcoreapp2.1 + week1_practice1 + + + diff --git a/week2-practice2/Program.cs b/week2-practice2/Program.cs new file mode 100644 index 00000000..3f019428 --- /dev/null +++ b/week2-practice2/Program.cs @@ -0,0 +1,32 @@ +using System; + +namespace week2_practice2 +{ + class Program + { + static void Main(string[] args) + { + int num; + + Console.WriteLine("Enter your grade: [must be an integer]"); + num = Convert.ToInt32(Console.ReadLine()); + + if (num >= 90) + { + Console.WriteLine("You made an A"); + } + else if (num >= 80) + { + Console.WriteLine("You made an B"); + } + else if (num >= 70) + { + Console.WriteLine("You made an C"); + } + else + { + Console.WriteLine("You did not pass"); + } + } + } +} diff --git a/week2-practice2/week2-practice2.csproj b/week2-practice2/week2-practice2.csproj new file mode 100644 index 00000000..378d9088 --- /dev/null +++ b/week2-practice2/week2-practice2.csproj @@ -0,0 +1,9 @@ + + + + Exe + netcoreapp2.1 + week2_2practice + + + diff --git a/week7-practice10/Program.cs b/week7-practice10/Program.cs new file mode 100644 index 00000000..d9c5a095 --- /dev/null +++ b/week7-practice10/Program.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; + +namespace week7_practice10 +{ + class Program + { + static void Main(string[] args) + { + Boat b1 = new Boat(40); + Boat b2 = new Boat(100); + + Room r1 = new Room(135); + Room r2 = new Room(300); + + List stuffToRent = new List(); + } + } + + public interface IRentable + { + double GetDailyRate(); + } + + public class Boat : IRentable + { + public double hourlyRate; + + public Boat(double hourly) + { + this.hourlyRate = hourly; + } + + public double GetDailyRate() + { + return hourlyRate * 24; + } + } + + public class Room : IRentable + { + public double dailyRate; + + public Room(double daily) + { + this.dailyRate = daily; + } + + public double GetDailyRate() + { + return dailyRate; + } + } +} diff --git a/week7-practice10/week7-practice10.csproj b/week7-practice10/week7-practice10.csproj new file mode 100644 index 00000000..bf27c8b7 --- /dev/null +++ b/week7-practice10/week7-practice10.csproj @@ -0,0 +1,9 @@ + + + + Exe + netcoreapp2.1 + week7_practice10 + + +