From 1df2f6d178d6ec865bcc81bfb8439fcc7b591e9a Mon Sep 17 00:00:00 2001 From: Wes Garbee Date: Sun, 7 Oct 2018 14:13:46 -0500 Subject: [PATCH 01/14] Created and built text adventure game --- TextGame/Program.cs | 141 ++++++++++++++++++++++++++++++++++ TextGame/TextAdventure.csproj | 8 ++ 2 files changed, 149 insertions(+) create mode 100644 TextGame/Program.cs create mode 100644 TextGame/TextAdventure.csproj diff --git a/TextGame/Program.cs b/TextGame/Program.cs new file mode 100644 index 00000000..9c07346e --- /dev/null +++ b/TextGame/Program.cs @@ -0,0 +1,141 @@ +using System; +using System.Threading; + +namespace TextAdventure +{ + class Program + { + static void Main(string[] args) + { + int stick = 0; + int complete; + Random randNum = new Random(); + + Console.Clear(); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + Console.WriteLine("Welcome to the cavern of secrets!"); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + + Thread.Sleep(3000); + + 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") + { + Console.WriteLine("You have taken the stick!"); + Thread.Sleep(2000); + stick = 1; + } + else + { + Console.WriteLine("You did not take the stick."); + Thread.Sleep(2000); + stick = 0; + } + + 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") + { + 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]"); + String ch3 = Console.ReadLine(); + Console.Clear(); + + if (ch3.ToUpper() == "Y" || ch3.ToUpper() == "YES") + { + if (stick == 1) + { + 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); + int fdmg1 = randNum.Next(3, 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) + { + Console.WriteLine("The spider has dealt more damage than you!"); + complete = 0; + } + else if (fdmg1 < 5) + { + Console.WriteLine("You didn't do enough damage to kill the spider, but you manage to escape!"); + complete = 1; + } + else + { + Console.WriteLine("You killed the spider!"); + complete = 1; + } + } + else + { + 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); + 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) + { + Console.WriteLine("The spider has dealt more damage than you!"); + complete = 0; + } + else if (fdmg1 < 5) + { + Console.WriteLine("You didn't do enough damage to kill the spider, but you manage to escape!"); + complete = 1; + } + else + { + Console.WriteLine("You killed the spider!"); + complete = 1; + } + } + } + else + { + 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 + { + 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; + } + } + } +} 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 + + + From dca4ddfd19294493967c7ec14287282647b4004c Mon Sep 17 00:00:00 2001 From: Wes Garbee Date: Mon, 8 Oct 2018 17:08:11 -0500 Subject: [PATCH 02/14] updated pieces of output text --- TextGame/Program.cs | 248 ++++++++++++++++++++++++++------------------ 1 file changed, 147 insertions(+), 101 deletions(-) diff --git a/TextGame/Program.cs b/TextGame/Program.cs index 9c07346e..5e693c13 100644 --- a/TextGame/Program.cs +++ b/TextGame/Program.cs @@ -10,131 +10,177 @@ static void Main(string[] args) int stick = 0; int complete; Random randNum = new Random(); + String playAgain; + Boolean alive = true; - Console.Clear(); - Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); - Console.WriteLine("Welcome to the cavern of secrets!"); - Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); - - Thread.Sleep(3000); + while (alive) + { + Console.Clear(); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + Console.WriteLine("Welcome to the cavern of secrets!"); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); - 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(); + Thread.Sleep(3000); - if (ch1.ToUpper() == "Y" || ch1.ToUpper() == "YES") - { - Console.WriteLine("You have taken the stick!"); - Thread.Sleep(2000); - stick = 1; - } - else - { - Console.WriteLine("You did not take the stick."); - Thread.Sleep(2000); - stick = 0; - } + 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(); - 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 (ch1.ToUpper() == "Y" || ch1.ToUpper() == "YES") + { + Console.WriteLine("You take the stick!"); + Thread.Sleep(2000); + stick = 1; + } + else + { + Console.WriteLine("You did not take the stick."); + Thread.Sleep(2000); + stick = 0; + } - if (ch2.ToUpper() == "Y" || ch2.ToUpper() == "YES") - { - 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]"); - String ch3 = Console.ReadLine(); + 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 (ch3.ToUpper() == "Y" || ch3.ToUpper() == "YES") + if (ch2.ToUpper() == "Y" || ch2.ToUpper() == "YES") { - if (stick == 1) - { - 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); - int fdmg1 = randNum.Next(3, 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); + 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]"); + String ch3 = Console.ReadLine(); + Console.Clear(); - if (edmg1 > fdmg1) - { - Console.WriteLine("The spider has dealt more damage than you!"); - complete = 0; - } - else if (fdmg1 < 5) + if (ch3.ToUpper() == "Y" || ch3.ToUpper() == "YES") + { + if (stick == 1) { - Console.WriteLine("You didn't do enough damage to kill the spider, but you manage to escape!"); - complete = 1; + 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); + 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) + { + Console.WriteLine("The spider has dealt more damage than you!"); + complete = 0; + } + else if (fdmg1 < 5) + { + Console.WriteLine("You didn't do enough damage to kill the spider, but you manage to escape!"); + complete = 1; + } + else + { + Console.WriteLine("You killed the spider!"); + complete = 1; + } } else { - Console.WriteLine("You killed the spider!"); - complete = 1; + 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); + 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) + { + Console.WriteLine("The spider has dealt more damage than you!"); + complete = 0; + } + else if (fdmg1 < 5) + { + Console.WriteLine("You didn't do enough damage to kill the spider, but you manage to escape!"); + complete = 1; + } + else + { + Console.WriteLine("You killed the spider!"); + complete = 1; + } } } else { - 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); - 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) - { - Console.WriteLine("The spider has dealt more damage than you!"); - complete = 0; - } - else if (fdmg1 < 5) - { - Console.WriteLine("You didn't do enough damage to kill the spider, but you manage to escape!"); - complete = 1; - } - else - { - Console.WriteLine("You killed the spider!"); - complete = 1; - } + 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 { - Console.WriteLine("You choose not to fight the spider."); + Console.WriteLine("You turn away from the glowing object, and attempt to leave the cave..."); Thread.Sleep(1000); - Console.WriteLine("As you turn away, it ambushes you and impales you with it's fangs!"); + Console.WriteLine("But something won't let you..."); + Thread.Sleep(2000); complete = 0; } - } - else - { - 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(); + } + } } } } From 0cf74799305ba59883bd456250cb36680d67e5af Mon Sep 17 00:00:00 2001 From: Wes Garbee Date: Mon, 8 Oct 2018 20:12:22 -0500 Subject: [PATCH 03/14] updated text adventure comments --- TextGame/Program.cs | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/TextGame/Program.cs b/TextGame/Program.cs index 5e693c13..979d00ac 100644 --- a/TextGame/Program.cs +++ b/TextGame/Program.cs @@ -13,15 +13,17 @@ static void Main(string[] args) String playAgain; Boolean alive = true; + // If alive == true, continue to run. Starts as true while (alive) { - Console.Clear(); + Console.Clear(); // Clears the console Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("Welcome to the cavern of secrets!"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); - Thread.Sleep(3000); + 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(); @@ -29,17 +31,20 @@ static void Main(string[] args) 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(); @@ -47,12 +52,14 @@ static void Main(string[] args) 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]"); + 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(); @@ -60,6 +67,7 @@ static void Main(string[] args) { 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); @@ -69,23 +77,24 @@ static void Main(string[] args) 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 (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) + 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 + else // If user damage is greater is greater than 5 { Console.WriteLine("You killed the spider!"); complete = 1; @@ -93,6 +102,7 @@ static void Main(string[] args) } else { + // If user doesn't have a stick Console.WriteLine("You don't have anything to fight with!"); Thread.Sleep(2000); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); @@ -101,23 +111,24 @@ static void Main(string[] args) 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 (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) + 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 + else // If user damage is greater is greater than 5 { Console.WriteLine("You killed the spider!"); complete = 1; @@ -126,6 +137,7 @@ static void Main(string[] args) } 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!"); @@ -134,6 +146,7 @@ static void Main(string[] args) } 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..."); From c13784da273f66f59b7f4d6aba247348073732cc Mon Sep 17 00:00:00 2001 From: Wes Garbee Date: Mon, 8 Oct 2018 20:22:28 -0500 Subject: [PATCH 04/14] adding practice file --- week1-practice1/Program.cs | 58 ++++++++++++++++++++++++++ week1-practice1/week1-practice1.csproj | 9 ++++ 2 files changed, 67 insertions(+) create mode 100644 week1-practice1/Program.cs create mode 100644 week1-practice1/week1-practice1.csproj 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 + + + From b76b5b0d86224c09de5063b8204013a853bfba79 Mon Sep 17 00:00:00 2001 From: Wes Garbee Date: Mon, 8 Oct 2018 20:23:42 -0500 Subject: [PATCH 05/14] update git ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index dfb074ab..c48595c4 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ obj .Trashes ehthumbs.db Thumbs.db +test \ No newline at end of file From 050dcff267d0dbe3a1c5ab6d66634f805a991f14 Mon Sep 17 00:00:00 2001 From: Wes Garbee Date: Mon, 8 Oct 2018 21:20:46 -0500 Subject: [PATCH 06/14] updated gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c48595c4..2d9cbb35 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,4 @@ obj .Trashes ehthumbs.db Thumbs.db -test \ No newline at end of file +test/* \ No newline at end of file From 3252185f9abe260052830025b7b1f62ec11d36ba Mon Sep 17 00:00:00 2001 From: Wes Garbee Date: Wed, 10 Oct 2018 19:37:41 -0500 Subject: [PATCH 07/14] week 2-2 practice --- week2-2practice/Program.cs | 36 ++++++++++++++++++++++++++ week2-2practice/week2-2practice.csproj | 9 +++++++ 2 files changed, 45 insertions(+) create mode 100644 week2-2practice/Program.cs create mode 100644 week2-2practice/week2-2practice.csproj diff --git a/week2-2practice/Program.cs b/week2-2practice/Program.cs new file mode 100644 index 00000000..177cb3f2 --- /dev/null +++ b/week2-2practice/Program.cs @@ -0,0 +1,36 @@ +using System; + +namespace week2_2practice +{ + 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 if (num >= 60) + { + Console.WriteLine("You made an D"); + } + else + { + Console.WriteLine("You did not pass"); + } + } + } +} diff --git a/week2-2practice/week2-2practice.csproj b/week2-2practice/week2-2practice.csproj new file mode 100644 index 00000000..378d9088 --- /dev/null +++ b/week2-2practice/week2-2practice.csproj @@ -0,0 +1,9 @@ + + + + Exe + netcoreapp2.1 + week2_2practice + + + From 6bae9ac11737dd78fe9c6095bee2c6b7e7b12530 Mon Sep 17 00:00:00 2001 From: Wes Garbee Date: Wed, 10 Oct 2018 19:55:18 -0500 Subject: [PATCH 08/14] fixed title of folder and files --- week2-practice2/Program.cs | 32 ++++++++++++++++++++++++++ week2-practice2/week2-practice2.csproj | 9 ++++++++ 2 files changed, 41 insertions(+) create mode 100644 week2-practice2/Program.cs create mode 100644 week2-practice2/week2-practice2.csproj 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 + + + From 6c59321fb09201184be4c21dde290647a9d2d185 Mon Sep 17 00:00:00 2001 From: Wes Garbee Date: Wed, 10 Oct 2018 19:59:16 -0500 Subject: [PATCH 09/14] removed deleted files --- week2-2practice/Program.cs | 36 -------------------------- week2-2practice/week2-2practice.csproj | 9 ------- 2 files changed, 45 deletions(-) delete mode 100644 week2-2practice/Program.cs delete mode 100644 week2-2practice/week2-2practice.csproj diff --git a/week2-2practice/Program.cs b/week2-2practice/Program.cs deleted file mode 100644 index 177cb3f2..00000000 --- a/week2-2practice/Program.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; - -namespace week2_2practice -{ - 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 if (num >= 60) - { - Console.WriteLine("You made an D"); - } - else - { - Console.WriteLine("You did not pass"); - } - } - } -} diff --git a/week2-2practice/week2-2practice.csproj b/week2-2practice/week2-2practice.csproj deleted file mode 100644 index 378d9088..00000000 --- a/week2-2practice/week2-2practice.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - Exe - netcoreapp2.1 - week2_2practice - - - From 408dc74c3590807b9d1b79ba8d0001313209d9aa Mon Sep 17 00:00:00 2001 From: Wes Garbee Date: Fri, 12 Oct 2018 09:45:41 -0500 Subject: [PATCH 10/14] Starting RPS program --- RockPaperScissors/RockPaperScissors.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index 470ae756..54b8e0ea 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; namespace RockPaperScissors { @@ -8,8 +9,9 @@ public static void Main() { Console.WriteLine("Enter hand 1:"); string hand1 = Console.ReadLine().ToLower(); - Console.WriteLine("Enter hand 2:"); - string hand2 = Console.ReadLine().ToLower(); + Random hand2 = new Random(1, 4); + // 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 From d80380c501f32e25a6af53573c2bb5ba2df041e9 Mon Sep 17 00:00:00 2001 From: Wes Garbee Date: Sat, 13 Oct 2018 19:40:49 -0500 Subject: [PATCH 11/14] added to the Compare method --- RockPaperScissors/RockPaperScissors.cs | 90 +++++++++++++++++++++++--- 1 file changed, 82 insertions(+), 8 deletions(-) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index 54b8e0ea..ff46676e 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -7,20 +7,94 @@ class Program { public static void Main() { - Console.WriteLine("Enter hand 1:"); - string hand1 = Console.ReadLine().ToLower(); - Random hand2 = new Random(1, 4); - // Console.WriteLine("Enter hand 2:"); - // string hand2 = Console.ReadLine().ToLower(); - Console.WriteLine(CompareHands(hand1, hand2)); + 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(); - // leave this command at the end so your program does not close automatically - Console.ReadLine(); + // If the user enters the word quit, terminates the program and clears the console + while (hand1.ToUpper() != "QUIT") + { + // Random number generator + Random randNum = new Random(); + string hand2 = Convert.ToString(randNum.Next(1, 4)); + + 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(); } 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; } } From a01e2a8c98e2f9b9d38f6205c4a9b8c1482b7dd5 Mon Sep 17 00:00:00 2001 From: Wes Garbee Date: Sun, 14 Oct 2018 15:58:23 -0500 Subject: [PATCH 12/14] updated comments --- RockPaperScissors/RockPaperScissors.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index ff46676e..6745264a 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -14,6 +14,7 @@ public static void Main() 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") @@ -29,6 +30,8 @@ public static void Main() 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(); From d7deda10e3844b0a2a234fa1e6eb02d0f0ac2678 Mon Sep 17 00:00:00 2001 From: Wes Garbee Date: Wed, 17 Oct 2018 18:50:25 -0500 Subject: [PATCH 13/14] Added comments --- RockPaperScissors/RockPaperScissors.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RockPaperScissors/RockPaperScissors.cs b/RockPaperScissors/RockPaperScissors.cs index 6745264a..1634fec3 100644 --- a/RockPaperScissors/RockPaperScissors.cs +++ b/RockPaperScissors/RockPaperScissors.cs @@ -19,10 +19,11 @@ public static void Main() // If the user enters the word quit, terminates the program and clears the console while (hand1.ToUpper() != "QUIT") { - // Random number generator + // 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); From 3b0e5e4513ec58f3782a0404a8ec5eb54801a5a4 Mon Sep 17 00:00:00 2001 From: Wes Garbee Date: Wed, 14 Nov 2018 19:38:38 -0600 Subject: [PATCH 14/14] w7p10 added --- week7-practice10/Program.cs | 54 ++++++++++++++++++++++++ week7-practice10/week7-practice10.csproj | 9 ++++ 2 files changed, 63 insertions(+) create mode 100644 week7-practice10/Program.cs create mode 100644 week7-practice10/week7-practice10.csproj 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 + + +