public void HandleMenuAction(MenuAction action) { switch (action) { case MenuAction.validate: license = new LicensePlate(); break; case MenuAction.invalid: break; default: break; } }
public void AskForValues() { string LicensePlate; string DateToVerify; string TimeToVerify; int n; DateTime dt; DateTime tv; Console.Clear(); do { Console.WriteLine("Please write the License Plate Number (XXX####) to Verify:"); LicensePlate = Console.ReadLine(); if ((Regex.IsMatch(LicensePlate.Substring(0, 3), @"^[a-zA-Z]+$")) && int.TryParse(LicensePlate.Substring(3, 4), out n) && !LicensePlate.Contains("-")) { this._letterSection = LicensePlate.Substring(0, 3); this._numberSection = Convert.ToInt32(LicensePlate.Substring(3, 4)); break; } else { Console.WriteLine("Invalid License Plate Number Format."); } } while (true); do { Console.WriteLine("Please write the Date (dd-mm-yyyy) to Verify:"); DateToVerify = Console.ReadLine(); if (DateTime.TryParseExact(DateToVerify, "dd-MM-yyyy", new CultureInfo("en-GB"), DateTimeStyles.None, out dt)) { this._date = Convert.ToDateTime(DateToVerify); break; } else { Console.WriteLine("Invalid Date Format."); } } while (true); do { Console.WriteLine("Please write the Time (hh:mm) to Verify:"); TimeToVerify = Console.ReadLine(); if (DateTime.TryParseExact(TimeToVerify, "HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out tv)) { this._time = TimeSpan.Parse(TimeToVerify); break; } else { Console.WriteLine("Invalid Time Format."); } } while (true); }