diff --git a/TextGame/TextGame.cs b/TextGame/TextGame.cs new file mode 100644 index 00000000..5f454a22 --- /dev/null +++ b/TextGame/TextGame.cs @@ -0,0 +1,159 @@ +using System; +using System.Threading; + +namespace TextGame +{ + class Program + { + static void Main(string[] args) + { + + int stick = 0; + + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + Console.WriteLine("Welcome to the cavern of secrets!"); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + + Thread.Sleep(3000); + //time pause method in C#(millsec) + + 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(); + + if (ch1 == "Y" || ch1 == "y" || ch1 == "Yes" || ch1 == "YES" || ch1 == "yes") + { + Console.WriteLine("You have taken the stick"); + Thread.Sleep(2000); + stick = 1; + } + else + { + Console.WriteLine("You did not take the stick"); + 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(); + + if (ch2 == "Y" || ch2 == "y" || ch2 == "Yes" || ch2 == "YES" || ch2 == "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(1); + Console.WriteLine("The eye belongs to a giant spider!"); + + + Console.WriteLine("Do you try to fight it? [Y/N]"); + + String ch3 = Console.ReadLine(); + + if (ch3 == "Y" || ch3 == "y" || ch3 == "Yes" || ch3 == "YES" || ch3 == "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); + + Random rnd = new Random(); + int fdmg1 = rnd.Next(3, 10); + int edmg1 = rnd.Next(1, 5); + + Console.WriteLine("you hit a {0}", fdmg1); + Console.WriteLine("the spider hits a {0}", edmg1); + Thread.Sleep(2000); + //generates random ints in the range entered after .Next + + int complete = 0; + + if (edmg1 > fdmg1) + { + Console.WriteLine("The spider has dealt more damage than you!"); + complete = 0; + return; + } + else if (fdmg1 < 5) + { + Console.WriteLine("You didn't do enough damage to kill the spider, but you manage to escape"); + complete = 1; + return; + } + else + { + Console.WriteLine("You killed the spider!"); + complete = 1; + return; + } + } + + else + { + Console.WriteLine("You don't have anything to fight with!"); + Console.WriteLine("You quickly jab it with your finger"); + 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); + + Random rnd = new Random(); + int fdmg1 = rnd.Next(1, 8); + int edmg1 = rnd.Next(1, 5); + + Console.WriteLine("you hit a {0}", fdmg1); + Console.WriteLine("the spider hits a {0}", edmg1); + Thread.Sleep(2000); + + int complete = 0; + + if (edmg1 > fdmg1) + { + Console.WriteLine("The spider has dealt more damage than you!"); + complete = 0; + return; + } + else if (fdmg1 < 5) + { + Console.WriteLine("You didn't do enough damage to kill the spider, but you manage to escape"); + complete = 1; + return; + } + else + { + Console.WriteLine("You killed the spider!"); + complete = 1; + return; + } + } + } + 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!!!"); + return; + + } + 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); + return; + + } + } + } +} +// be extremely mindful of indentation/formatting/alignment!!! \ No newline at end of file diff --git a/TextGame/TextGame.csproj b/TextGame/TextGame.csproj new file mode 100644 index 00000000..23df6047 --- /dev/null +++ b/TextGame/TextGame.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/Week1-Practice.cs b/Week1-Practice.cs new file mode 100644 index 00000000..84a82396 --- /dev/null +++ b/Week1-Practice.cs @@ -0,0 +1,35 @@ +using System; + +public class Program +{ + public static void Main() + { + string name = ""; + string lastname = ""; + int age = 0; + int year = 7; + string band = ""; + string team = ""; + + + Console.WriteLine("Please enter your first name:"); + // ReadLine enters the string + name = Console.ReadLine(); + Console.WriteLine("Please enter your last name:"); + lastname = Console.ReadLine(); + Console.WriteLine("Please enter your age:"); + // Convert.ToInt32 takes in the numbers + age = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Who is your favorite band:"); + band = Console.ReadLine(); + Console.WriteLine("What sports team do you cheer for:"); + team = Console.ReadLine(); + + + Console.WriteLine + (@"Hello! My name is {0} {1}. + I am {3} in dog years. + My favorite band is {4}. + I support {5}! ", name, lastname, age, year * age, band, team); + } +} diff --git a/csharp-workbook.csproj b/csharp-workbook.csproj new file mode 100644 index 00000000..d06178dc --- /dev/null +++ b/csharp-workbook.csproj @@ -0,0 +1,9 @@ + + + + Exe + netcoreapp2.1 + csharp_workbook + + + diff --git a/week1-Practice/week1-Practice.cs b/week1-Practice/week1-Practice.cs new file mode 100644 index 00000000..4f0ea126 --- /dev/null +++ b/week1-Practice/week1-Practice.cs @@ -0,0 +1,74 @@ +using System; + +public class Program +{ + public static void Main() + { + + int one = 0; + int two = 0; + + Console.WriteLine("Please enter a whole number:"); + one = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Please enter a whole number:"); + two = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("{0} + {1} = {2}", one, two, one + two); + + int yard = 12; + int inch = 12; + + Console.WriteLine("12 yards is {0} inches", yard * inch); + + decimal num = 3.35m; + // m suffix used with decimal + + Console.WriteLine("The product of NUM(3.35) is {0}", num * num); + + bool people = true; + Console.WriteLine(people); + + bool f = false; + Console.WriteLine(f); + // you told me to use f as the variable + + string name = ""; + string lastname = ""; + int age = 0; + int year = 2018; + // adjust to current year + string job = ""; + string band = ""; + string team = ""; + + Console.WriteLine("Please enter your first name:"); + // ReadLine enters the string + name = Console.ReadLine(); + Console.WriteLine("Please enter your last name:"); + lastname = Console.ReadLine(); + Console.WriteLine("Please enter your age:"); + // Convert.ToInt32 takes in the numbers + age = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("What is your Job?"); + job = Console.ReadLine(); + Console.WriteLine("Who is your favorite band?"); + band = Console.ReadLine(); + Console.WriteLine("What sports team do you cheer for?"); + team = Console.ReadLine(); + + + Console.WriteLine(@"Hello! My name is {0} {1}.", name, lastname); + Console.WriteLine("I was born in {1}.", age, year - age); + Console.WriteLine("I work as a {0}.", job); + Console.WriteLine("My favorite band is {0}.", band); + Console.WriteLine("I support {0}! ", team); + + int hund = 100; + int ten = 10; + + Console.WriteLine("The Sum of 100 and 10 = {0}", hund + ten); + Console.WriteLine("The Product of 100 and 10 = {0}", hund * ten); + Console.WriteLine("The Difference of 100 and 10 = {0}", hund - ten); + Console.WriteLine("The Quotient of 100 and 10 = {0}", hund / ten); + + } +} diff --git a/week1-Practice/week1-Practice.csproj b/week1-Practice/week1-Practice.csproj new file mode 100644 index 00000000..6b3e6080 --- /dev/null +++ b/week1-Practice/week1-Practice.csproj @@ -0,0 +1,9 @@ + + + + Exe + netcoreapp2.1 + week1_Practice + + +