diff --git a/PigLatin/PigLatin.cs b/PigLatin/PigLatin.cs
index 702647dd..255c149d 100644
--- a/PigLatin/PigLatin.cs
+++ b/PigLatin/PigLatin.cs
@@ -1,21 +1,78 @@
using System;
+using System.Collections.Generic;
namespace PigLatin
{
class Program
{
- public static void Main()
+ public static void Main(string[] args)
{
- // your code goes here
+ // run tests and print out if tests passed or not
+ if(tests()){
+ Console.WriteLine("Tests passed.");
+ } else {
+ Console.WriteLine("Tests failed.");
+ }
- // leave this command at the end so your program does not close automatically
- Console.ReadLine();
+ //your code to get user input and call TranslateWord method here
+
+ string word = "";
+
+
+ Console.WriteLine("Translate to Pig Latin, Enter a word {0}", word);
+ word = Console.ReadLine();
+ string pigLatin = ToPigLatin(word);
+ Console.WriteLine(pigLatin);
+
}
-
- public static string TranslateWord(string word)
+
+ public static string ToPigLatin(string word)
{
- // your code goes here
- return word;
+ string vowels = "AEIOUaeio";
+ string PigWorded = "";
+
+
+ string firstLetter = word.Substring(0,1);
+
+ Console.WriteLine(firstLetter);
+
+ string restOfWord = word.Substring(1, word.Length -1);
+ Console.WriteLine(restOfWord);
+
+ int currentLetter = vowels.IndexOf(firstLetter);
+ Console.WriteLine(currentLetter);
+ if (currentLetter == -1)
+ {
+ PigWorded += (restOfWord + firstLetter + "ay");
+ }
+ else
+ {
+ PigWorded += (word + "yay");
+ }
+
+
+ return PigWorded;
+
+ }
+ /**
+ This method tests some examples against the 5 following rules,
+ and returns true if all tests pass, otherwise returns false.
+
+ rule 1: if it starts with a vowel add "yay" to the end
+ rule 2: move all letter before the first vowel to the end, then add "ay" to the end
+ rule 3: if it starts with a "y", treat the "y" as a consonant
+ rule 4: if it does not start with a "y", treat the "y" as a vowel
+ rule 5: if there are no vowels, add "ay" to the end (this is the same as rule 2)
+ */
+ public static bool tests(){
+ return
+ ToPigLatin("elephant") == "elephantyay" &&
+ ToPigLatin("fox") == "oxfay" &&
+ ToPigLatin("choice") == "oicechay" &&
+ ToPigLatin("dye") == "yeday" &&
+ ToPigLatin("bystander") == "ystanderbay" &&
+ ToPigLatin("yellow") == "ellowyay" &&
+ ToPigLatin("tsktsk") == "tsktskay";
}
}
}
diff --git a/Today/Today.cs b/Today/Today.cs
new file mode 100644
index 00000000..cb0eec76
--- /dev/null
+++ b/Today/Today.cs
@@ -0,0 +1,26 @@
+using System;
+using System.IO;
+
+namespace Today
+{
+ class Today
+ {
+ static void Main(string[] args)
+ {
+ String file = @"/Users/jasonconnolly/Desktop/words.txt";
+ String[] lines = File.ReadAllLines(file);
+ //reading all lines and putting in an array
+
+ int lineNo =0;
+ foreach(String line in lines){
+ lineNo +=1;
+ Console.WriteLine(lineNo+"+line");
+ //reading each line and then writing to the console
+ }
+
+ String copy= @"/Users/jasonconnolly/Desktop/.txt";
+ File.WriteAllLines(copy, lines);
+ //creates new file and puts into new file
+ }
+ }
+}
diff --git a/Today/Today.csproj b/Today/Today.csproj
new file mode 100644
index 00000000..23df6047
--- /dev/null
+++ b/Today/Today.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.1
+
+
+
diff --git a/Today/test.txt b/Today/test.txt
new file mode 100644
index 00000000..b6cb3c87
--- /dev/null
+++ b/Today/test.txt
@@ -0,0 +1 @@
+Hello Yousif
\ No newline at end of file
diff --git a/Todo/Todo.cs b/Todo/Todo.cs
new file mode 100644
index 00000000..59e64d2c
--- /dev/null
+++ b/Todo/Todo.cs
@@ -0,0 +1,627 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Globalization;
+using System.Security.Permissions;
+using System.Threading;
+
+namespace To_Do_List
+{
+ public class To_do : IComparable
+ {
+ public int Todo_ID { get; set; }
+ public DateTime date { get; set; }
+ public string Task { get; set; }
+ public int Lvl_Imp { get; set; }
+
+ public To_do(int Todo_ID, DateTime date, string Task, int Lvl_Imp)
+ {
+ this.Todo_ID = Todo_ID;
+ this.date = date;
+ this.Task = Task;
+ this.Lvl_Imp = Lvl_Imp;
+ }
+ public int CompareTo(To_do other)
+ {
+ return this.Todo_ID.CompareTo(other.Todo_ID);
+ }
+
+ }
+
+
+ class Program
+ {
+ //commonly used string tabbing
+ public static string mt = "\t\t\t";
+ public static string st = "\t\t ";
+ public static string xst = "\t\t";
+
+ //UI
+ public static void header() //Draw the main Menu Header
+ {
+ Console.Clear();
+ DateTime dtu = DateTime.Now;
+
+ Console.WriteLine("\n\n\n\t\t\t\t\t" + dtu.ToString("MM-dd-yyyy"));
+ Console.WriteLine("\t\t====================================");
+ Console.WriteLine("\t\t\t TO-DO List");
+ Console.WriteLine("\t\t====================================");
+ }
+
+ public static void footer() //Draw the main Menu Footer
+ {
+ Console.WriteLine("\t\t====================================");
+ }
+
+
+
+ public static void Prompt(String msg) //Deliver common error messages and instructions
+ {
+ header();
+ Console.WriteLine("\n\n" + st + msg + "\n\n");
+ footer();
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ }
+
+
+ public static bool chk_date(String dateChk) //checking for a valid date entry
+ {
+ string[] formats = { "M-d-yyyy" };
+ DateTime parsedDateTime;
+ if (DateTime.TryParseExact(dateChk, formats, new CultureInfo("en-US"),
+ DateTimeStyles.None, out parsedDateTime))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public static void Main()
+ {
+ Random rnd = new Random();
+ int ID = rnd.Next(89); //generate random ID
+
+ List TD_Task = new List(); //setup the list container, just storing to memory fix this
+ bool check = true; ;
+
+ MAIN: //main menu
+
+ while (true)
+ {
+
+
+ header(); //Todo Menu
+ Console.WriteLine(xst + "1.New Task.\t\t6.Update Task.\n");
+ Console.WriteLine(xst + "2.View All.\t\t7.Delete Task.\n");
+ Console.WriteLine(xst + "3.View b/w Dates.\t8.Sort.\n");
+ Console.WriteLine(xst + "4.Find Task.\t\t9.Exit\n");
+ Console.WriteLine(xst + "5.Find Duplicates.");
+ footer();
+
+ Console.Write(st + "Enter your choice: ");
+ int ch = 0;
+ try
+ {
+ ch = int.Parse(Console.ReadLine());
+ }
+ catch (Exception)
+ {
+
+ Prompt("ERROR: Insert Only Intergers!");
+ }
+
+ //Menu options and Error Catching based on selection (ch)
+ switch (ch)
+ {
+ case 1:
+ header();
+ Console.Write("\t\tEnter the Date.\t[MM-dd-yyyy]\n\t\t");
+ try
+ {
+ string dateEntry = Console.ReadLine();
+ string storedDateEntry = dateEntry;
+
+ DateTime cur_time = DateTime.Now;
+ cur_time.ToString("M-d-yyyy");
+ try
+ {
+ TimeSpan duration = DateTime.Parse(cur_time.ToString()) - (DateTime.Parse(dateEntry.ToString()));
+
+
+ int day = (int)Math.Round(duration.TotalDays);
+
+ int x = 0;
+ if (day % 2 != 0)
+ {
+ x = 2;
+ }
+ else
+ {
+ x = 1;
+ }
+
+
+ if (day >= x) // if date less than todays
+ {
+ DateTime dtu = DateTime.Now;
+ string msg = "Please select date from\n\t\t" + dtu.ToString("M-d-yyyy") + " onwards!";
+ Prompt("ERROR: " + msg);
+ goto MAIN;
+ }
+
+ }
+ catch (FormatException)
+ {
+ Prompt("ERROR: Invalid Date!");
+ goto MAIN;
+
+ }
+
+
+
+ if (chk_date(storedDateEntry)) // check validity of date
+ {
+ Console.Write("\n\t\tEnter Task.\n\t\t");
+ string msg = Console.ReadLine();
+
+ Console.Write("\n\t\tEnter Level of Importance.\t[1-5]\n\t\t");
+ int lvl = int.Parse(Console.ReadLine());
+ if (lvl >= 1 && lvl <= 5)
+ {
+ ID++;
+
+ TD_Task.Add(new To_do(ID, DateTime.Parse(dateEntry), msg, lvl));
+ Prompt("New Task created with Task ID = " + ID.ToString());
+ TD_Task.Sort(); // Sort db
+ }
+ else
+ {
+ Prompt("ERROR: Only between [1-5]!");
+ }
+ }
+ else
+ {
+ Prompt("ERROR: Invalid Date!");
+ }
+
+
+ }
+ catch (Exception)
+ {
+ Prompt("ERROR: Enter Integer Only!!");
+ }
+ break;
+
+ case 2:
+ header();
+ Console.WriteLine("\t\tID \tDate\tTask\t\tLevel");
+
+ foreach (To_do x in TD_Task)
+ {
+ check = false;
+ Console.WriteLine("\t\t" + x.Todo_ID + " " + x.date.ToString("MM-dd-yyyy") + "\t" + x.Task + "\t\t" + x.Lvl_Imp);
+ }
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\tNo Records Found!\n\n");
+ }
+ footer();
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ break;
+
+ case 3:
+
+ header();
+
+ string cmp_date1, mon1, day1, S_d, E_d, S_m, E_m, S_da, E_da;
+ int SD, ED, cmp_date, mon, SM, EM, dayx, SDA, EDA;
+
+ Console.Write("\t\tEnter starting Date.\t[MM-dd-yyyy]\n\t\t");
+ string Sdat3 = Console.ReadLine();
+
+ if (chk_date(Sdat3)) // enter validity of date
+ {
+ Console.Write("\n\t\tEnter ending Date.\t[MM-dd-yyyy]\n\t\t");
+ string Edat3 = Console.ReadLine();
+ Console.WriteLine("\t\t------------------------------------");
+ Console.WriteLine("\t\tID \tDate\tTask\tLevel");
+
+ if (chk_date(Edat3)) // check validity of date
+ {
+
+ DateTime s = DateTime.Parse(Sdat3);
+ DateTime e = DateTime.Parse(Edat3);
+
+
+ for (int i = 0; i < TD_Task.Count; i++)
+ {
+ //year
+ cmp_date1 = TD_Task[i].date.ToString("yyyy");
+ cmp_date = int.Parse(cmp_date1);
+ S_d = s.ToString("yyyy");
+ E_d = e.ToString("yyyy");
+ SD = int.Parse(S_d);
+ ED = int.Parse(E_d);
+
+ //month
+ mon1 = TD_Task[i].date.ToString("MM");
+ mon = int.Parse(mon1);
+ S_m = s.ToString("MM");
+ E_m = e.ToString("MM");
+ SM = int.Parse(S_m);
+ EM = int.Parse(E_m);
+
+ //day
+ day1 = TD_Task[i].date.ToString("dd");
+ dayx = int.Parse(day1);
+ S_da = s.ToString("dd");
+ E_da = e.ToString("dd");
+ SDA = int.Parse(S_da);
+ EDA = int.Parse(E_da);
+
+ if (cmp_date >= SD && cmp_date <= ED) // Range of Years
+ {
+ if (mon >= SM && mon <= EM) // Range of Months
+ {
+ if (dayx >= SDA && dayx <= EDA) // Range of Days
+ {
+ check = false;
+ Console.WriteLine("\t\t" + TD_Task[i].Todo_ID + " " + TD_Task[i].date.ToString("MM-dd-yyyy") + "\t " + TD_Task[i].Task + "\t " + TD_Task[i].Lvl_Imp);
+ }
+ }
+ }
+ }
+
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\tNo Records Found!\n\n");
+ }
+ footer();
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+ }
+ else
+ {
+ Prompt("ERROR: Invalid Ending Date!");
+ }
+ }
+ else
+ {
+ Prompt("ERROR: Invalid Starting Date!");
+ }
+
+ break;
+
+ case 4:
+ header();
+ Console.Write("\t\tEnter the String.\n\t\t");
+ try
+ {
+ string str1;
+ string str = Console.ReadLine();
+ str.ToLower();
+ Console.WriteLine("\t\t------------------------------------");
+ Console.WriteLine("\t\tID \tDate\tTask\tLevel");
+ for (int i = 0; i < TD_Task.Count; i++)
+ {
+ str1 = TD_Task[i].Task;
+ str1.ToLower();
+ if (str1.Contains(str))
+ {
+ check = false;
+ Console.WriteLine("\t\t" + TD_Task[i].Todo_ID + " " + TD_Task[i].date.ToString("MM-dd-yyyy") + "\t " + TD_Task[i].Task + "\t " + TD_Task[i].Lvl_Imp);
+ }
+
+
+ }
+
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\tNo Records Found!\n\n");
+ }
+ footer();
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+ }
+ catch (Exception)
+ {
+
+ Prompt("Error in Find string");
+ }
+
+
+ break;
+
+ case 5:
+ header();
+ Console.WriteLine("\t\t------------------------------------");
+ Console.WriteLine("\t\tID \tDate\tTask\tLevel");
+ string a;
+ int z = 0;
+ foreach (To_do y in TD_Task)
+ {
+ a = y.Task;
+
+
+ z = 0;
+ foreach (To_do x in TD_Task)
+ {
+
+ if (a.Equals(x.Task))
+ {
+ z++;
+
+ }
+
+
+ }
+ if (z >= 2)
+ {
+ check = false;
+ Console.WriteLine("\t\t" + y.Todo_ID + " " + y.date.ToString("MM-dd-yyyy") + "\t" + y.Task + "\t" + y.Lvl_Imp);
+ }
+ }
+
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t No Duplicate Records Found!\n\n");
+ }
+
+ footer();
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ break;
+
+ case 6:
+ header();
+ Console.Write("\t\tEnter the Task_ID.\n\t\t");
+ try
+ {
+ int T_ID = int.Parse(Console.ReadLine());
+ Console.WriteLine("\t\t------------------------------------");
+ for (int i = 0; i < TD_Task.Count; i++)
+ {
+ if (TD_Task[i].Todo_ID == T_ID)
+ {
+ check = false;
+ Console.Write("\t\tEnter the Date.\t[MM-dd-yyyy]\n\t\t");
+ try
+ {
+ string dateEntry = Console.ReadLine();
+ string storedDateEntry = dateEntry;
+
+ DateTime cur_time = DateTime.Now;
+ cur_time.ToString("M-d-yyyy");
+ try
+ {
+ TimeSpan duration = DateTime.Parse(cur_time.ToString()) - (DateTime.Parse(dateEntry.ToString()));
+
+
+ int day = (int)Math.Round(duration.TotalDays);
+
+ if (day >= 2) // if date less than todays
+ {
+ DateTime dtu = DateTime.Now;
+ string msg = "Plz select date from\n\t\t" + dtu.ToString("M-d-yyyy") + " onwards!";
+ Prompt("ERROR: " + msg);
+ goto MAIN;
+ }
+
+ }
+ catch (FormatException)
+ {
+ Prompt("ERROR: Invalid Date!");
+ goto MAIN;
+
+ }
+
+
+
+ if (chk_date(storedDateEntry)) // check validity of date
+ {
+ Console.Write("\n\t\tEnter Task.\n\t\t");
+ string msg = Console.ReadLine();
+
+ Console.Write("\n\t\tEnter Level of Importance.\t[1-5]\n\t\t");
+ int lvl = int.Parse(Console.ReadLine());
+ if (lvl >= 1 && lvl <= 5)
+ {
+
+
+ TD_Task[i].date = DateTime.Parse(dateEntry);
+ TD_Task[i].Task = msg;
+ TD_Task[i].Lvl_Imp = lvl;
+
+ Console.WriteLine("\t\tTask Updated!");
+ TD_Task.Sort(); // Sort db
+ }
+ else
+ {
+ Prompt("ERROR: Only between [1-5]!");
+ }
+ }
+ else
+ {
+ Prompt("ERROR: Invalid Date!");
+ }
+
+
+ }
+ catch (Exception)
+ {
+ Prompt("ERROR: Enter Integer Only!!");
+ }
+
+ }
+ }
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\t No Record Found!\n\n");
+ }
+ footer();
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ }
+ catch (Exception)
+ {
+
+ Prompt("ERROR: Insert Only Intergers!");
+ }
+ break;
+
+ case 7:
+ header();
+ Console.Write("\t\tEnter the Task_ID.\n\t\t");
+ try
+ {
+ int T_ID = int.Parse(Console.ReadLine());
+ Console.WriteLine("\t\t------------------------------------");
+ for (int i = 0; i < TD_Task.Count; i++)
+ {
+ if (TD_Task[i].Todo_ID == T_ID)
+ {
+ check = false;
+ TD_Task.RemoveAll(e => e.Todo_ID == T_ID);
+ }
+ }
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\t No Record Found!\n\n");
+ }
+ else
+ {
+ Console.WriteLine("\n\n\t\t\t Record Deleted!\n\n");
+
+ }
+ footer();
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ }
+ catch (Exception)
+ {
+
+ Prompt("ERROR: Insert Only Intergers!");
+ }
+ break;
+
+
+ case 8:
+
+ while (true)
+ {
+ header();
+ Console.WriteLine("\t\t\t1.Sort By ID.");
+ Console.WriteLine("\t\t\t2.Sort By DATE.");
+ Console.WriteLine("\t\t\t3.Sort By Level Of Importance.");
+ Console.WriteLine("\t\t\t4.Exit.");
+ footer();
+ Console.Write(st + "Enter your choice: ");
+ ch = int.Parse(Console.ReadLine());
+
+ switch (ch)
+ {
+
+ case 1:
+
+ header();
+ Console.WriteLine("\t\tID \tDate\tTask\tLevel");
+ Console.WriteLine("\t\t------------------------------------");
+ TD_Task = TD_Task.OrderBy(x => x.Todo_ID).ToList();
+ foreach (To_do x in TD_Task)
+ {
+ check = false;
+ Console.WriteLine("\t\t" + x.Todo_ID + " " + x.date.ToString("MM-dd-yyyy") + "\t" + x.Task + "\t" + x.Lvl_Imp);
+ }
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\tNo Records Found!\n\n");
+ }
+ footer();
+ TD_Task = TD_Task.OrderBy(x => x.date).ToList();
+
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ break;
+
+ case 2:
+
+ header();
+ Console.WriteLine("\t\tID \tDate\tTask\tLevel");
+ Console.WriteLine("\t\t------------------------------------");
+ TD_Task = TD_Task.OrderBy(x => x.date).ToList();
+ foreach (To_do x in TD_Task)
+ {
+ check = false;
+ Console.WriteLine("\t\t" + x.Todo_ID + " " + x.date.ToString("MM-dd-yyyy") + "\t" + x.Task + "\t" + x.Lvl_Imp);
+ }
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\tNo Records Found!\n\n");
+ }
+ footer();
+ TD_Task = TD_Task.OrderBy(x => x.date).ToList();
+
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ break;
+
+ case 3:
+
+ header();
+ Console.WriteLine("\t\tID \tDate\tTask\tLevel");
+ Console.WriteLine("\t\t------------------------------------");
+ TD_Task = TD_Task.OrderBy(x => x.Lvl_Imp).ToList();
+ TD_Task.Reverse();
+ foreach (To_do x in TD_Task)
+ {
+ check = false;
+ Console.WriteLine("\t\t" + x.Todo_ID + " " + x.date.ToString("MM-dd-yyyy") + "\t" + x.Task + "\t" + x.Lvl_Imp);
+ }
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\tNo Records Found!\n\n");
+ }
+ footer();
+ TD_Task = TD_Task.OrderBy(x => x.date).ToList();
+
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ break;
+ case 4:
+ goto MAIN;
+
+
+ default:
+ Prompt("Invalid choice!");
+ break;
+ }
+
+ }
+
+ case 9:
+ Environment.Exit(0);
+ break;
+
+ default:
+ Prompt("Invalid choice!");
+ break;
+
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Todo/Todo.csproj b/Todo/Todo.csproj
new file mode 100644
index 00000000..23df6047
--- /dev/null
+++ b/Todo/Todo.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.1
+
+
+
diff --git a/Week9.cs b/Week9.cs
new file mode 100644
index 00000000..43c125e0
--- /dev/null
+++ b/Week9.cs
@@ -0,0 +1,626 @@
+using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using System.Globalization;
+ using System.Security.Permissions;
+ using System.Threading;
+
+ namespace To_Do_List_Tuhin
+ {
+ public class To_do : IComparable
+ {
+ public int Todo_ID { get; set; }
+ public DateTime date { get; set; }
+ public string Task { get; set; }
+ public int Lvl_Imp { get; set; }
+
+ public To_do(int Todo_ID, DateTime date, string Task, int Lvl_Imp)
+ {
+ this.Todo_ID = Todo_ID;
+ this.date = date;
+ this.Task = Task;
+ this.Lvl_Imp = Lvl_Imp;
+ }
+ public int CompareTo(To_do other)
+ {
+ return this.Todo_ID.CompareTo(other.Todo_ID);
+ }
+
+ }
+
+
+ class Program
+ {
+ public static string mt = "\t\t\t";
+ public static string st = "\t\t ";
+ public static string xst = "\t\t";
+
+ //UI
+ public static void header()
+ {
+ Console.Clear();
+ DateTime dtu = DateTime.Now;
+
+ Console.WriteLine("\n\n\n\t\t\t\t\t" + dtu.ToString("dd-MM-yyyy"));
+ Console.WriteLine("\t\t====================================");
+ Console.WriteLine("\t\t\t TO-DO List");
+ Console.WriteLine("\t\t====================================");
+ }
+
+ public static void footer()
+ {
+ Console.WriteLine("\t\t====================================");
+ }
+
+
+
+ public static void UI_msg(String msg)
+ {
+ header();
+ Console.WriteLine("\n\n" + st + msg + "\n\n");
+ footer();
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ }
+
+
+ public static bool chk_date(String daaat)
+ {
+ string[] formats = { "d-M-yyyy" };
+ DateTime parsedDateTime;
+ if (DateTime.TryParseExact(daaat, formats, new CultureInfo("en-US"),
+ DateTimeStyles.None, out parsedDateTime))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public static void Main()
+ {
+ Random rnd = new Random();
+ int ID = rnd.Next(89);
+
+ List TD_Task = new List();
+ bool check = true; ;
+
+ SUDO_MAIN:
+
+ while (true)
+ {
+
+
+ header();
+ Console.WriteLine(xst + "1.New Task.\t\t6.Update Task.\n");
+ Console.WriteLine(xst + "2.View Al.\t\t7.Delete Task.\n");
+ Console.WriteLine(xst + "3.View b/w Dates.\t8.Sort.\n");
+ Console.WriteLine(xst + "4.Find Task.\t\t9.Exit\n");
+ Console.WriteLine(xst + "5.Find Duplicates.");
+ footer();
+
+ Console.Write(st + "Enter your choice: ");
+ int ch = 0;
+ try
+ {
+ ch = int.Parse(Console.ReadLine());
+ }
+ catch (Exception)
+ {
+
+ UI_msg("ERROR: Insert Only Intergers!");
+ }
+
+
+ switch (ch)
+ {
+ case 1:
+ header();
+ Console.Write("\t\tEnter the Date.\t[dd-MM-yyyy]\n\t\t");
+ try
+ {
+ string dat = Console.ReadLine();
+ string daat = dat;
+
+ DateTime cur_time = DateTime.Now;
+ cur_time.ToString("d-M-yyyy");
+ try
+ {
+ TimeSpan duration = DateTime.Parse(cur_time.ToString()) - (DateTime.Parse(dat.ToString()));
+
+
+ int day = (int)Math.Round(duration.TotalDays);
+
+ int x=0 ;
+ if (day % 2 != 0)
+ {
+ x = 2;
+ }
+ else
+ {
+ x = 1;
+ }
+
+
+ if (day >= x) // if date less than todays
+ {
+ DateTime dtu = DateTime.Now;
+ string msg = "Plz select date from\n\t\t" + dtu.ToString("d-M-yyyy") + " onwards!";
+ UI_msg("ERROR: " + msg);
+ goto SUDO_MAIN;
+ }
+
+ }
+ catch (FormatException)
+ {
+ UI_msg("ERROR: Invalid Date!");
+ goto SUDO_MAIN;
+
+ }
+
+
+
+ if (chk_date(daat)) // check validity of date
+ {
+ Console.Write("\n\t\tEnter Task.\n\t\t");
+ string msg = Console.ReadLine();
+
+ Console.Write("\n\t\tEnter Level of Importance.\t[1-5]\n\t\t");
+ int lvl = int.Parse(Console.ReadLine());
+ if (lvl >= 1 && lvl <= 5)
+ {
+ ID++;
+
+ TD_Task.Add(new To_do(ID, DateTime.Parse(dat), msg, lvl));
+ UI_msg("New Task created with Task ID = " + ID.ToString());
+ TD_Task.Sort(); // Sort db
+ }
+ else
+ {
+ UI_msg("ERROR: Only between [1-5]!");
+ }
+ }
+ else
+ {
+ UI_msg("ERROR: Invalid Date!");
+ }
+
+
+ }
+ catch (Exception)
+ {
+ UI_msg("ERROR: Enter Integer Only!!");
+ }
+ break;
+
+ case 2:
+ header();
+ Console.WriteLine("\t\tID \tDate\tTask\t\tLevel");
+
+ foreach (To_do x in TD_Task)
+ {
+ check = false;
+ Console.WriteLine("\t\t" + x.Todo_ID + " " + x.date.ToString("dd-MM-yyyy") + "\t" + x.Task + "\t\t" + x.Lvl_Imp);
+ }
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\tNo Records Found!\n\n");
+ }
+ footer();
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ break;
+
+ case 3:
+
+ header();
+
+ string cmp_date1, mon1, day1, S_d, E_d, S_m, E_m, S_da, E_da;
+ int SD, ED, cmp_date, mon, SM, EM, dayx, SDA, EDA;
+
+ Console.Write("\t\tEnter starting Date.\t[dd-MM-yyyy]\n\t\t");
+ string Sdat3 = Console.ReadLine();
+
+ if (chk_date(Sdat3)) // check validity of date
+ {
+ Console.Write("\n\t\tEnter ending Date.\t[dd-MM-yyyy]\n\t\t");
+ string Edat3 = Console.ReadLine();
+ Console.WriteLine("\t\t------------------------------------");
+ Console.WriteLine("\t\tID \tDate\tTask\tLevel");
+
+ if (chk_date(Edat3)) // check validity of date
+ {
+
+ DateTime s = DateTime.Parse(Sdat3);
+ DateTime e = DateTime.Parse(Edat3);
+
+
+ for (int i = 0; i < TD_Task.Count; i++)
+ {
+ //year
+ cmp_date1 = TD_Task[i].date.ToString("yyyy");
+ cmp_date = int.Parse(cmp_date1);
+ S_d = s.ToString("yyyy");
+ E_d = e.ToString("yyyy");
+ SD = int.Parse(S_d);
+ ED = int.Parse(E_d);
+
+ //month
+ mon1 = TD_Task[i].date.ToString("MM");
+ mon = int.Parse(mon1);
+ S_m = s.ToString("MM");
+ E_m = e.ToString("MM");
+ SM = int.Parse(S_m);
+ EM = int.Parse(E_m);
+
+ //day
+ day1 = TD_Task[i].date.ToString("dd");
+ dayx = int.Parse(day1);
+ S_da = s.ToString("dd");
+ E_da = e.ToString("dd");
+ SDA = int.Parse(S_da);
+ EDA = int.Parse(E_da);
+
+ if (cmp_date >= SD && cmp_date <= ED) // Range of Years
+ {
+ if (mon >= SM && mon <= EM) // Range of Months
+ {
+ if (dayx >= SDA && dayx <= EDA) // Range of Days
+ {
+ check = false;
+ Console.WriteLine("\t\t" + TD_Task[i].Todo_ID + " " + TD_Task[i].date.ToString("dd-MM-yyyy") + "\t " + TD_Task[i].Task + "\t " + TD_Task[i].Lvl_Imp);
+ }
+ }
+ }
+ }
+
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\tNo Records Found!\n\n");
+ }
+ footer();
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+ }
+ else
+ {
+ UI_msg("ERROR: Invalid Ending Date!");
+ }
+ }
+ else
+ {
+ UI_msg("ERROR: Invalid Starting Date!");
+ }
+
+ break;
+
+ case 4:
+ header();
+ Console.Write("\t\tEnter the String.\n\t\t");
+ try
+ {
+ string str1;
+ string str = Console.ReadLine();
+ str.ToLower();
+ Console.WriteLine("\t\t------------------------------------");
+ Console.WriteLine("\t\tID \tDate\tTask\tLevel");
+ for (int i = 0; i < TD_Task.Count; i++)
+ {
+ str1 = TD_Task[i].Task;
+ str1.ToLower();
+ if (str1.Contains(str))
+ {
+ check = false;
+ Console.WriteLine("\t\t" + TD_Task[i].Todo_ID + " " + TD_Task[i].date.ToString("dd-MM-yyyy") + "\t " + TD_Task[i].Task + "\t " + TD_Task[i].Lvl_Imp);
+ }
+
+
+ }
+
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\tNo Records Found!\n\n");
+ }
+ footer();
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+ }
+ catch (Exception)
+ {
+
+ UI_msg("Error in Find string");
+ }
+
+
+ break;
+
+ case 5:
+ header();
+ Console.WriteLine("\t\t------------------------------------");
+ Console.WriteLine("\t\tID \tDate\tTask\tLevel");
+ string a;
+ int z=0;
+ foreach (To_do y in TD_Task)
+ {
+ a = y.Task;
+
+
+ z = 0;
+ foreach (To_do x in TD_Task)
+ {
+
+ if (a.Equals(x.Task))
+ {
+ z++;
+
+ }
+
+
+ }
+ if (z >= 2)
+ {
+ check = false;
+ Console.WriteLine("\t\t" + y.Todo_ID + " " + y.date.ToString("dd-MM-yyyy") + "\t" + y.Task + "\t" + y.Lvl_Imp);
+ }
+ }
+
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t No Duplicate Records Found!\n\n");
+ }
+
+ footer();
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ break;
+
+ case 6:
+ header();
+ Console.Write("\t\tEnter the Task_ID.\n\t\t");
+ try
+ {
+ int T_ID = int.Parse(Console.ReadLine());
+ Console.WriteLine("\t\t------------------------------------");
+ for (int i = 0; i < TD_Task.Count; i++)
+ {
+ if (TD_Task[i].Todo_ID == T_ID)
+ {
+ check = false;
+ Console.Write("\t\tEnter the Date.\t[dd-MM-yyyy]\n\t\t");
+ try
+ {
+ string dat = Console.ReadLine();
+ string daat = dat;
+
+ DateTime cur_time = DateTime.Now;
+ cur_time.ToString("d-M-yyyy");
+ try
+ {
+ TimeSpan duration = DateTime.Parse(cur_time.ToString()) - (DateTime.Parse(dat.ToString()));
+
+
+ int day = (int)Math.Round(duration.TotalDays);
+
+ if (day >= 2) // if date less than todays
+ {
+ DateTime dtu = DateTime.Now;
+ string msg = "Plz select date from\n\t\t" + dtu.ToString("d-M-yyyy") + " onwards!";
+ UI_msg("ERROR: " + msg);
+ goto SUDO_MAIN;
+ }
+
+ }
+ catch (FormatException)
+ {
+ UI_msg("ERROR: Invalid Date!");
+ goto SUDO_MAIN;
+
+ }
+
+
+
+ if (chk_date(daat)) // check validity of date
+ {
+ Console.Write("\n\t\tEnter Task.\n\t\t");
+ string msg = Console.ReadLine();
+
+ Console.Write("\n\t\tEnter Level of Importance.\t[1-5]\n\t\t");
+ int lvl = int.Parse(Console.ReadLine());
+ if (lvl >= 1 && lvl <= 5)
+ {
+
+
+ TD_Task[i].date = DateTime.Parse(dat);
+ TD_Task[i].Task = msg;
+ TD_Task[i].Lvl_Imp = lvl;
+
+ Console.WriteLine("\t\tTask Updated!");
+ TD_Task.Sort(); // Sort db
+ }
+ else
+ {
+ UI_msg("ERROR: Only between [1-5]!");
+ }
+ }
+ else
+ {
+ UI_msg("ERROR: Invalid Date!");
+ }
+
+
+ }
+ catch (Exception)
+ {
+ UI_msg("ERROR: Enter Integer Only!!");
+ }
+
+ }
+ }
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\t No Record Found!\n\n");
+ }
+ footer();
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ }
+ catch (Exception)
+ {
+
+ UI_msg("ERROR: Insert Only Intergers!");
+ }
+ break;
+
+ case 7:
+ header();
+ Console.Write("\t\tEnter the Task_ID.\n\t\t");
+ try
+ {
+ int T_ID = int.Parse(Console.ReadLine());
+ Console.WriteLine("\t\t------------------------------------");
+ for (int i = 0; i < TD_Task.Count; i++)
+ {
+ if (TD_Task[i].Todo_ID == T_ID)
+ {
+ check = false;
+ TD_Task.RemoveAll(e => e.Todo_ID == T_ID);
+ }
+ }
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\t No Record Found!\n\n");
+ }
+ else
+ {
+ Console.WriteLine("\n\n\t\t\t Record Deleted!\n\n");
+
+ }
+ footer();
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ }
+ catch (Exception)
+ {
+
+ UI_msg("ERROR: Insert Only Intergers!");
+ }
+ break;
+
+
+ case 8:
+
+ while (true)
+ {
+ header();
+ Console.WriteLine("\t\t\t1.Sort By ID.");
+ Console.WriteLine("\t\t\t2.Sort By DATE.");
+ Console.WriteLine("\t\t\t3.Sort By Level Of Importance.");
+ Console.WriteLine("\t\t\t4.Exit.");
+ footer();
+ Console.Write(st + "Enter your choice: ");
+ ch = int.Parse(Console.ReadLine());
+
+ switch (ch)
+ {
+
+ case 1:
+
+ header();
+ Console.WriteLine("\t\tID \tDate\tTask\tLevel");
+ Console.WriteLine("\t\t------------------------------------");
+ TD_Task = TD_Task.OrderBy(x => x.Todo_ID).ToList();
+ foreach (To_do x in TD_Task)
+ {
+ check = false;
+ Console.WriteLine("\t\t" + x.Todo_ID + " " + x.date.ToString("dd-MM-yyyy") + "\t" + x.Task + "\t" + x.Lvl_Imp);
+ }
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\tNo Records Found!\n\n");
+ }
+ footer();
+ TD_Task = TD_Task.OrderBy(x => x.date).ToList();
+
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ break;
+
+ case 2:
+
+ header();
+ Console.WriteLine("\t\tID \tDate\tTask\tLevel");
+ Console.WriteLine("\t\t------------------------------------");
+ TD_Task = TD_Task.OrderBy(x => x.date).ToList();
+ foreach (To_do x in TD_Task)
+ {
+ check = false;
+ Console.WriteLine("\t\t" + x.Todo_ID + " " + x.date.ToString("dd-MM-yyyy") + "\t" + x.Task + "\t" + x.Lvl_Imp);
+ }
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\tNo Records Found!\n\n");
+ }
+ footer();
+ TD_Task = TD_Task.OrderBy(x => x.date).ToList();
+
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ break;
+
+ case 3:
+
+ header();
+ Console.WriteLine("\t\tID \tDate\tTask\tLevel");
+ Console.WriteLine("\t\t------------------------------------");
+ TD_Task = TD_Task.OrderBy(x => x.Lvl_Imp).ToList();
+ TD_Task.Reverse();
+ foreach (To_do x in TD_Task)
+ {
+ check = false;
+ Console.WriteLine("\t\t" + x.Todo_ID + " " + x.date.ToString("dd-MM-yyyy") + "\t" + x.Task + "\t" + x.Lvl_Imp);
+ }
+ if (check)
+ {
+ Console.WriteLine("\n\n\t\t\tNo Records Found!\n\n");
+ }
+ footer();
+ TD_Task = TD_Task.OrderBy(x => x.date).ToList();
+
+ Console.Write(st + "Press key to continue:");
+ Console.ReadKey();
+
+ break;
+ case 4:
+ goto SUDO_MAIN;
+
+
+ default:
+ UI_msg("Invalid choice!");
+ break;
+ }
+
+ }
+
+ case 9:
+ Environment.Exit(0);
+ break;
+
+ default:
+ UI_msg("Invalid choice!");
+ break;
+
+ }
+ }
+ }
+ }
+ }
\ No newline at end of file
diff --git a/Week9/Program.cs b/Week9/Program.cs
new file mode 100644
index 00000000..2ab31d63
--- /dev/null
+++ b/Week9/Program.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Week9
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello World!");
+ }
+ }
+}
diff --git a/Week9/Week7.csproj b/Week9/Week7.csproj
new file mode 100644
index 00000000..23df6047
--- /dev/null
+++ b/Week9/Week7.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.1
+
+
+
diff --git a/Week9/Week9.csproj b/Week9/Week9.csproj
new file mode 100644
index 00000000..23df6047
--- /dev/null
+++ b/Week9/Week9.csproj
@@ -0,0 +1,8 @@
+
+
+
+ Exe
+ netcoreapp2.1
+
+
+
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/week10/week10.cs b/week10/week10.cs
new file mode 100644
index 00000000..8f1b1aed
--- /dev/null
+++ b/week10/week10.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.EntityFrameworkCore;
+
+namespace week10
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Student john = new Student(1, "John Doe");
+ Student jane = new Student(2, "Jane Doe");
+
+ Console.WriteLine(jane);
+ Console.WriteLine(john);
+ }
+ }
+ public class Student
+ {
+ public int id { get; set; }
+ public String name { get; set; }
+
+ public Student(int id, String name)
+ {
+ this.id = id;
+ this.name = name;
+ }
+ override
+ public string ToString()
+ {
+ return id + ":" + name;
+ }
+ }
+ public class Context : DbContext
+ {
+ public DbSet myStudents { get; set; }
+ override
+ protected void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ optionsBuilder.UseSqlite("Filename=./students.db");
+
+ }
+
+
+ }
+}
diff --git a/week10/week10.csproj b/week10/week10.csproj
new file mode 100644
index 00000000..56f6f2cf
--- /dev/null
+++ b/week10/week10.csproj
@@ -0,0 +1,12 @@
+
+
+
+ Exe
+ netcoreapp2.1
+
+
+
+
+
+
+