public static List <TouringTrip> ReadDate(string path) { List <TouringTrip> g = new List <TouringTrip>(); string text = ""; using (StreamReader sr = new StreamReader(path)) { text = sr.ReadToEnd(); } string[] Times = text.Split('/'); foreach (string s in Times) { string[] MetaDete = s.Split('|'); if (MetaDete.Length == 5) { TouringTrip d = new TouringTrip { Coment = MetaDete[0], Time = MetaDete[1], Count = Convert.ToInt32(MetaDete[2]), Name = MetaDete[3], Address = MetaDete[4] }; g.Add(d); } } return(g); }
public override int Smallest(List <TouringTrip> lst) { Console.Clear(); int IndexMin = 0; foreach (TouringTrip gs in lst) { if (lst[IndexMin].Count > gs.Count) { IndexMin = lst.IndexOf(gs); } } int MaxI = 8; int MaxN = 4; int MaxW = 9; int MaxC = 10; int MaxL = 8; TouringTrip g = lst[IndexMin]; Console.WriteLine("|Коментар| Час |Кiлькiсть| Прiзвище | Адреса |"); int ni = MaxI - Convert.ToString(g.Coment.Trim()).Length; int nn = MaxN - g.Time.Count(); int nw = MaxW - Convert.ToString(g.Count).Length; int nc = MaxC - Convert.ToString(g.Name).Length; int nl = MaxL - Convert.ToString(g.Address).Length; Console.WriteLine("|" + Convert.ToString(g.Coment.Trim()) + PS(ni) + "|" + g.Time + PS(nn) + "|" + Convert.ToString(g.Count) + PS(nw) + "|" + Convert.ToString(g.Name) + PS(nc) + "|" + Convert.ToString(g.Address) + PS(nl) + "|"); return(g.Count); }
//------------------------------------------------------------------- public override int Smallest(List <TouringTrip> lst) { Console.Clear(); int IndexMin = 0; foreach (TouringTrip gs in lst) { if (lst[IndexMin].Count > gs.Count) { IndexMin = lst.IndexOf(gs); } } int MaxI = 8; int MaxN = 12; int MaxW = 7; int MaxC = 15; int MaxL = 11; TouringTrip g = lst[IndexMin]; Console.WriteLine("| Coment |Time\t| Count | Surname | Address |"); int ni = MaxI - Convert.ToString(g.Coment.Trim()).Length; int nn = MaxN - g.Time.Count(); int nw = MaxW - Convert.ToString(g.Count).Length; int nc = MaxC - Convert.ToString(g.Name).Length; int nl = MaxL - Convert.ToString(g.Address).Length; Console.WriteLine("|" + Convert.ToString(g.Coment.Trim()) + PS(ni) + "|" + g.Time + PS(nn) + "\t|" + Convert.ToString(g.Count) + PS(nw) + "|" + Convert.ToString(g.Name) + PS(nc) + "|" + Convert.ToString(g.Address) + PS(nl) + "|"); return(g.Count); }
public static void ChangeDate(List <TouringTrip> Time) { Console.WriteLine("Введiть час:"); string Nam = Console.ReadLine(); TouringTrip Choosen = new TouringTrip(); Choosen.Name = ""; foreach (TouringTrip g in Time) { if (g.Time == Nam) { Choosen = g; break; } } if (Choosen.Name != "") { Console.WriteLine(); Console.WriteLine("1)Змiнити коментар\n2)Змiнити час\n3)Змiнити кiлькiсть\n4)Змiнити прiзвище\n5)Змiнити адресу\n6)Видалити"); char key = Console.ReadKey().KeyChar; Console.WriteLine("Введiть нове значення:"); try { if (key == '1') { Choosen.Coment = Console.ReadLine(); } if (key == '2') { Choosen.Time = Console.ReadLine(); } if (key == '3') { Choosen.Count = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(Choosen.Count); } if (key == '4') { Choosen.Name = Console.ReadLine(); } if (key == '5') { Choosen.Address = Console.ReadLine(); } if (key == '6') { Time.Remove(Choosen); } } catch { Console.WriteLine("нове значення не правильне"); } } else { Console.WriteLine("TouringTrip не знайдено"); } }
public static void ChangeDate(List <TouringTrip> Time) { Console.WriteLine("Enter Time that`s need to change"); string Nam = Console.ReadLine(); TouringTrip Choosen = new TouringTrip(); Choosen.Name = ""; foreach (TouringTrip g in Time) { if (g.Time == Nam) { Choosen = g; break; } } if (Choosen.Name != "") { Console.WriteLine(); Console.WriteLine("1)Change Coment\n2)Change Time\n3)Change Count\n4)Change Name\n5)Change Address\n6)Delete"); char key = Console.ReadKey().KeyChar; Console.WriteLine("Enter new value"); try { if (key == '1') { Choosen.Coment = Console.ReadLine(); } if (key == '2') { Choosen.Time = Console.ReadLine(); } if (key == '3') { Choosen.Count = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(Choosen.Count); } if (key == '4') { Choosen.Name = Console.ReadLine(); } if (key == '5') { Choosen.Address = Console.ReadLine(); } if (key == '6') { Time.Remove(Choosen); } } catch { Console.WriteLine("New value is incorrect"); } } else { Console.WriteLine("TouringTrip Not found"); } }
public static void AddNew(List <TouringTrip> Date) { Console.WriteLine("Введiть коментар"); TouringTrip neww = new TouringTrip(); neww.Coment = Console.ReadLine(); Console.WriteLine("Введiть час"); neww.Time = Console.ReadLine(); Console.WriteLine("Введiть кiлькiсть"); neww.Count = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Введiть прiзвище"); neww.Name = Console.ReadLine(); Console.WriteLine("Введiть адресу"); neww.Address = Console.ReadLine(); Date.Add(neww); }
public static void AddNew(List <TouringTrip> Date) { Console.WriteLine("Enter Comment"); TouringTrip neww = new TouringTrip(); neww.Coment = Console.ReadLine(); Console.WriteLine("Enter Time"); neww.Time = Console.ReadLine(); Console.WriteLine("Enter Count"); neww.Count = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Surname"); neww.Name = Console.ReadLine(); Console.WriteLine("Enter Address"); neww.Address = Console.ReadLine(); Date.Add(neww); }