//case 4 private static HTable Case4(HTable hTable, ref string[] array, ref string[] keyIndex) { Array.Resize(ref array, array.Length + 1); Array.Resize(ref keyIndex, keyIndex.Length + 1); var rgx = new Regex(@"[0-9]"); string addPerson; string[] add; Console.WriteLine("Write second name, name and father name of the person, whose you want to add:"); do { addPerson = Console.ReadLine(); if (rgx.IsMatch(addPerson)) { Console.WriteLine("Error! Written the number..."); } var separator = " ".ToCharArray(); add = addPerson.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (add.Length != 3) { Console.WriteLine( "Error! The wrong input...\nWrite second name, name and father name of teh person:"); } } while (addPerson == "" || rgx.IsMatch(addPerson) || add.Length != 3); var rnd = new Random(); var person = new Person(add[0], add[1], add[2], CreateAccount(rnd), rnd.Next(0, 1000000).ToString()); array[array.Length - 1] = person.ToString(); keyIndex[keyIndex.Length - 1] = string.Concat(add[0], add[1], add[2]); if (hTable.SearchPerson(addPerson) == null) { hTable.FillingHashTable(keyIndex, array, hTable.Size + 1, out _); Console.WriteLine("{0} is added to the hash-table:", add[0] + " " + add[1] + " " + add[2]); hTable.PrintHt(); } else { Console.WriteLine("The person is already added to the hash-table..."); } Console.WriteLine(Index[5]); Console.ReadKey(); return(hTable); }
//Печать меню для функции Main() private static bool PrintMenu(ref int pass, ref HTable hTable, ref string[] array, ref string[] keyIndex) { var ok = true; var sw = Print.Menu(pass, Index[0], Index[1], Index[2], Index[3], Index[6], Index[4]); switch (sw) { case 1: hTable = Case1(out pass, out array, out keyIndex); break; case 2: Case2(hTable); break; case 3: hTable = Case3(hTable, ref array, ref keyIndex); break; case 4: hTable = Case4(hTable, ref array, ref keyIndex); break; case 5: hTable.PrintHt(); Console.WriteLine(Index[5]); Console.ReadKey(); break; case 6: ok = false; break; } return(ok); }