public static void ChangeDate(List <TouringTrip> Date) { Console.WriteLine("Enter Date of trip that`s need to change"); string Nam = Console.ReadLine(); TouringTrip Choosen = new TouringTrip(); Choosen.Name = ""; foreach (TouringTrip g in Date) { if (g.Date == Nam) { Choosen = g; break; } } if (Choosen.Name != "") { Console.WriteLine(); Console.WriteLine("1)Change City\n2)Change Date\n3)Change Count\n4)Change Name\n5)Change Head Name\n6)Delete"); char key = Console.ReadKey().KeyChar; Console.WriteLine("Enter new value"); try { if (key == '1') { Choosen.City = Console.ReadLine(); } if (key == '2') { Choosen.Date = 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.HeadName = Console.ReadLine(); } if (key == '6') { Date.Remove(Choosen); } } catch { Console.WriteLine("New value is incorrect"); } //Lviv|29.03.2019|7|Great Pistols|Ridme/ } else { Console.WriteLine("TouringTrip Not found"); } }
//------------------------------------------------------------------- public override int MaxCount(List <TouringTrip> lst) { Console.Clear(); int IndexMax = 0; foreach (TouringTrip gs in lst) { if (gs.Count > lst[IndexMax].Count) { IndexMax = lst.IndexOf(gs); } } int MaxI = 8; int MaxN = 12; int MaxW = 7; int MaxC = 15; int MaxL = 11; TouringTrip g = lst[IndexMax]; Console.WriteLine("| City | Date | Count | GroupName | Head Name |"); int ni = MaxI - Convert.ToString(g.City.Trim()).Length; int nn = MaxN - g.Date.Count(); int nw = MaxW - Convert.ToString(g.Count).Length; int nc = MaxC - Convert.ToString(g.Name).Length; int nl = MaxL - Convert.ToString(g.HeadName).Length; Console.WriteLine("|" + Convert.ToString(g.City.Trim()) + PS(ni) + "|" + g.Date + PS(nn) + "|" + Convert.ToString(g.Count) + PS(nw) + "|" + Convert.ToString(g.Name) + PS(nc) + "|" + Convert.ToString(g.HeadName) + PS(nl) + "|"); return(g.Count); }
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[] Dates = text.Split('/'); foreach (string s in Dates) { string[] MetaDete = s.Split('|'); if (MetaDete.Length == 5) { TouringTrip d = new TouringTrip { City = MetaDete[0], Date = MetaDete[1], Count = Convert.ToInt32(MetaDete[2]), Name = MetaDete[3], HeadName = MetaDete[4] }; g.Add(d); } } return(g); }
public static void AddNew(List <TouringTrip> Date) { Console.WriteLine("Enter City"); TouringTrip neww = new TouringTrip(); neww.City = Console.ReadLine(); Console.WriteLine("Enter Date"); neww.Date = Console.ReadLine(); Console.WriteLine("Enter Count"); neww.Count = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Group Name"); neww.Name = Console.ReadLine(); Console.WriteLine("Enter Head Name"); neww.HeadName = Console.ReadLine(); Date.Add(neww); }