From a1bc87bccfaa1e103d20528d930e150039bff39f Mon Sep 17 00:00:00 2001 From: TerryRoberts1995 Date: Wed, 31 Oct 2018 22:09:59 -0500 Subject: [PATCH 1/4] Exceptions --- RSP2/RPS2.cs | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 RSP2/RPS2.cs diff --git a/RSP2/RPS2.cs b/RSP2/RPS2.cs new file mode 100644 index 00000000..02d4ddd0 --- /dev/null +++ b/RSP2/RPS2.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; + +namespace RockPaperScissors +{ + class Program + { + public static void Main() + { + Console.WriteLine("Enter hand 1:"); + string hand1 = Console.ReadLine().ToLower(); + + + + string hand2; + Random pcturn = new Random(); + int answer = pcturn.Next(1,4); + + if (answer == 1) + { + hand2 ="rock"; + } + else if (answer == 2) + { + hand2 = "paper"; + } + else + { + hand2 = "scissors"; + } + Console.WriteLine(hand2); + + 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) + { + if (hand1 == hand2) + { + return "It's a tie!"; + } + + if (hand1 == "rock") + { + if (hand2 == "scissors") + { + return "Hand one wins!"; + } + else + { + return "Hand two wins!"; + } + } + + if (hand1 == "paper") + { + if(hand2 == "rock") + { + return "Hand one wins!"; + } + else + { + return "Hand two wins!"; + } + } + + if (hand1 == "scissors") + { + if(hand2 == "paper") + { + return "Hand one wins!"; + } + else + { + return "Hand two wins!"; + } + + } + return hand1 + ' ' + hand2; + } + } +} From 8b04a4e30a8eb7161b9e4f201e9366cb40ad6d25 Mon Sep 17 00:00:00 2001 From: TerryRoberts1995 Date: Thu, 8 Nov 2018 02:30:32 -0600 Subject: [PATCH 2/4] Finished Gradebook --- Grades/Grades.cs | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Grades/Grades.cs diff --git a/Grades/Grades.cs b/Grades/Grades.cs new file mode 100644 index 00000000..d76d2f2a --- /dev/null +++ b/Grades/Grades.cs @@ -0,0 +1,70 @@ +using System; +using System.Linq; +using System.Collections.Generic; +namespace practice_week4 +{ + class Program + { + static void Main(string[] args) + { + Dictionary> grades = getStudent(); + foreach(var key in grades.Keys) + { + Console.WriteLine("Students Name: " + key); + Console.WriteLine("The Average grade is " + grades [key].Average()); + Console.WriteLine("The Minimum grade is " + grades [key].Min()); + Console.WriteLine("The Max grade is " + grades [key].Max()); + } + + } + public static Dictionary> getStudent() + { + Dictionary> grades = new Dictionary>(); + //Prompt User to Add names of the Student they want to add. + Console.WriteLine("What is the Students name? "); + string name = Console.ReadLine(); + grades.Add(name, getStudentGrade()); + Console.WriteLine("Do you want to add another Student?"); + string keepAdding = Console.ReadLine().ToLower(); + + + while(keepAdding != "no") + { + Console.WriteLine("What is the students name?"); + string newAnswer = Console.ReadLine(); + grades.Add(newAnswer, getStudentGrade()); + Console.WriteLine("Do you want to add another Student?"); + keepAdding = Console.ReadLine(); + } + return grades; + } + public static List getStudentGrade() + { + + List gradebook = new List(); + + Console.WriteLine("What is the Students grade?"); + int grade = Convert.ToInt32(Console.ReadLine()); + + gradebook.Add(grade); + + Console.WriteLine("Do you want to add another grade?"); + + string x = Console.ReadLine().ToLower(); + while (x != "no") + { + + Console.WriteLine("What is the grade"); + int numAnswer = Convert.ToInt32(Console.ReadLine()); + gradebook.Add(numAnswer); + + Console.WriteLine("Add another"); + x = Console.ReadLine(); + + } + + return gradebook; + + } + } +} \ No newline at end of file From b2a66fd9ab0b0c541e9c5215cdd4849e21ca5e28 Mon Sep 17 00:00:00 2001 From: TerryRoberts1995 Date: Thu, 20 Dec 2018 01:44:47 -0600 Subject: [PATCH 3/4] Finished Linq --- Linq/Linq.cs | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/Linq/Linq.cs b/Linq/Linq.cs index 6cabb44e..b6d7a16f 100644 --- a/Linq/Linq.cs +++ b/Linq/Linq.cs @@ -1,12 +1,48 @@ using System; +using System.Collections.Generic; +using System.Linq; + namespace Linq { class Program { - static void Main(string[] args) + static void Main() { - Console.WriteLine("Hello World!"); + List students = new List(); + + students.Add(new Student("Chris", "123-456-7891", "123 Delany", -2990)); + students.Add(new Student("Terry", "198-765-4321", "321 ynaled", -2500)); + students.Add(new Student("Victoria", "512-827-8498", "701 Brazos St", 0)); + students.Add(new Student("Luke", "555-555-5555", "451 Brody Ln", -500)); + students.Add(new Student("Jessica", "210-895-6658", "578 Blackhill blvd",-3600)); + + IEnumerable negativeBalance = from currentStudent in students + where currentStudent.Balance < 0 + select currentStudent; + + Console.WriteLine("All the students with a negative balance"); + foreach(Student currentStudent in negativeBalance) + { + Console.WriteLine(currentStudent.Name); + } + + } + } + public class Student + { + public string Name {get; set;} + public string Phone {get; set;} + public string Address {get; set;} + public int Balance {get; set;} + + public Student(string name, string phone, string address , int balance) + { + + Name = name; + Phone = phone; + Address = address; + Balance = balance; } } } From 9307ae22353f87e0231cde97d6ce6daccf1783d9 Mon Sep 17 00:00:00 2001 From: TerryRoberts1995 Date: Thu, 20 Dec 2018 04:09:14 -0600 Subject: [PATCH 4/4] Enum finished --- Enums/Enum.cs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Enums/Enum.cs diff --git a/Enums/Enum.cs b/Enums/Enum.cs new file mode 100644 index 00000000..7322b392 --- /dev/null +++ b/Enums/Enum.cs @@ -0,0 +1,41 @@ +using System; + +public class Program +{ + public static void Main() + { + //Days into Years that Birday occurs + int myBirthday = 9; + //day of week -1 for 1950 + int dayOfWeekTracker = -1; + //Enter a year + Console.WriteLine("Enter Year"); + //Take input for year. + int year = Convert.ToInt16(Console.ReadLine()); + + //increments a counter by 1 on normal years and by 2 on leap year to keep track of the week day shift through years + for(int yearCheck = 1950; yearCheck <= year; yearCheck++) + { + //if is a leap year add 2 days. + if(yearCheck % 4 == 0) + { + dayOfWeekTracker += 2; + } + else + //if not leap year add 1. + { + dayOfWeekTracker++; + } + //calculates day of week that birthday lands on. + int DayOfWeek = (myBirthday+dayOfWeekTracker) % 7; + //Writes year and day of the week that birthday lands on. + Console.WriteLine("Year "+ (year)+ " " + (DaysOfWeek)(DayOfWeek)); + Console.ReadLine(); + } + } + //enum storing the days of the week. + enum DaysOfWeek + { + Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday + } +}