static void Leaving(Customer c, TourClub tc) { Console.WriteLine($"Do you want to leave a tour club {tc.Name}? (y/n)"); string answer1 = Console.ReadLine(); while (((answer1 != "y" && answer1 != "Y" && answer1 != "yes" && answer1 != "Yes") || (answer1 != "n" || answer1 != "No" || answer1 != "no" || answer1 != "No"))) { if (answer1 == "y" || answer1 == "Y" || answer1 == "yes" || answer1 == "Yes") { c.LeaveClub(tc); break; } else if (answer1 == "n" || answer1 == "N" || answer1 == "no" || answer1 == "No") { break; } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Incorrect answer format"); Console.ResetColor(); } } }
static bool Finding(Customer tmp, TourClub tourclub) { // Console.WriteLine("Do you want to find a tour? (y / n))"); string answer = Console.ReadLine(); if (answer == "y" || answer == "Y" || answer == "yes" || answer == "Yes") { // Console.WriteLine("Finding by: Price(1), Country(2), Tour agency(3), Date(4), Theme(5) :"); string s = Console.ReadLine(); int t = 0; try { t = Convert.ToInt32(s); } catch (FormatException) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Not a number"); Console.ResetColor(); } while (t != 1 && t != 2 && t != 3 && t != 4 && t != 5) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("you need to write a right number"); Console.ResetColor(); s = Console.ReadLine(); try { t = Convert.ToInt32(s); } catch (FormatException) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Not a number"); Console.ResetColor(); } } string str = ""; switch (t) { case 1: Console.WriteLine("Enter max price you want: "); double tt = 0; try { tt = Convert.ToDouble(Console.ReadLine()); } catch (FormatException) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("---Not a number, max prise set to 0---"); Console.ResetColor(); } tmp.AddTour(tourclub.FindByPrice(tt)); break; case 2: Console.WriteLine("Enter country you want: "); str = Console.ReadLine(); tmp.AddTour(tourclub.FindByCountry(str)); break; case 3: Console.WriteLine("Enter agency you want: "); str = Console.ReadLine(); tmp.AddTour(tourclub.FindByAgency(str)); break; case 4: Console.WriteLine("Enter date you want: "); Console.Write("year: "); int year = DateTime.Now.Month, month = DateTime.Now.Month, day = DateTime.Now.Day; try { year = Convert.ToInt32(Console.ReadLine()); } catch (FormatException) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Not a number, year set to now"); Console.ResetColor(); } Console.Write("month: "); try { month = Convert.ToInt32(Console.ReadLine()); } catch (FormatException) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Not a number, month set to now"); Console.ResetColor(); } Console.Write("day: "); try { day = Convert.ToInt32(Console.ReadLine()); } catch (FormatException) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Not a number, day set to now"); Console.ResetColor(); } tmp.AddTour(tourclub.FindByDate(new DateTime(year, month, day))); break; case 5: Console.WriteLine("Enter theme you want: "); str = Console.ReadLine(); tmp.AddTour(tourclub.FindByTheme(str)); break; } return(true); } else if (answer == "n" || answer == "N" || answer == "no" || answer == "No") { return(false); } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Incorrect answer format"); Console.ResetColor(); return(Finding(tmp, tourclub)); } }