Ejemplo n.º 1
0
        /// <summary>
        /// Processes user choice
        /// </summary>
        /// <param name="set">Hash table</param>
        /// <param name="choice">User choice</param>
        static private void PerformUserDesire(HashTable <string> set, int choice)
        {
            switch (choice)
            {
            case 0:
                break;

            case 1:
            {
                Console.Write("Enter the key to find:  ");
                string key = Console.ReadLine();
                if (set.IsExist(key))
                {
                    Console.WriteLine("Exists\n");
                    break;
                }
                Console.WriteLine("Doesn't exist\n");
                break;
            }

            case 2:
            {
                Console.Write("Enter the key to add:  ");
                string key = Console.ReadLine();
                if (set.AddToSet(key))
                {
                    Console.WriteLine("Success!\n");
                    break;
                }
                Console.WriteLine("Such a key already exists\n");
                break;
            }

            case 3:
            {
                Console.Write("Enter the key to delete:  ");
                string key = Console.ReadLine();
                if (set.DeleteFromSet(key))
                {
                    Console.WriteLine("Success!\n");
                    break;
                }
                Console.WriteLine("No such a key\n");
                break;
            }

            case 4:
                set.PrintHashTable();
                break;

            case 5:
                Console.Clear();
                PrintHashTableOptions();
                break;

            default:
                Console.WriteLine("No such option\n");
                break;
            }
        }
Ejemplo n.º 2
0
 public void CheckIsExistsOnNonExistentValue(int key)
 {
     Assert.IsFalse(set.IsExist(key));
 }
Ejemplo n.º 3
0
 public void IsExistOnEmptySet(int key)
 {
     Assert.IsFalse(emptySet.IsExist(key));
 }