// accept, parse, and execute user commands private static void commandLoop() { string command = ""; string[] commandWords; Console.Write("Welcome to Harry's Dutch Bingo Parlor!\n"); while (command != "exit") { Console.Write("\nEnter a command: "); command = Console.ReadLine(); commandWords = Regex.Split(command, @"\s+"); // split input into array of words command = commandWords[0]; if (command == "exit") { ; // do nothing } // read a relationship graph from a file else if (command == "read" && commandWords.Length > 1) { ReadRelationshipGraph(commandWords[1]); } // show information for one person else if (command == "show" && commandWords.Length > 1) { ShowPerson(commandWords[1]); } else if (command == "friends" && commandWords.Length > 1) { ShowFriends(commandWords[1]); } // dump command prints out the graph else if (command == "dump") { rg.dump(); } //show people without parents else if (command == "orphans") { Orphans(); } //shows descendants of person else if (command == "descendants" && commandWords.Length > 1) { Descendants(commandWords[1]); } // illegal command else { Console.Write("\nLegal commands: read [filename], dump, show [personname],\n friends [personname], orphans, descendants [personname], exit\n"); } } }
// accept, parse, and execute user commands private static void commandLoop() { string command = ""; string[] commandWords; Console.Write("Welcome to Harry's Dutch Bingo Parlor!\n"); while (command != "exit") { Console.Write("\nEnter a command: "); command = Console.ReadLine(); commandWords = Regex.Split(command, @"\s+"); // split input into array of words command = commandWords[0]; if (command == "exit") { ; // do nothing } // read a relationship graph from a file else if (command == "read" && commandWords.Length > 1) { ReadRelationshipGraph(commandWords[1]); } // show information for one person else if (command == "show" && commandWords.Length > 1) { ShowPerson(commandWords[1]); } // show all the friends of a person else if (command == "friends" && commandWords.Length > 1) { ShowFriends(commandWords[1]); } // show all the people who are orphans (have no parents) else if (command == "orphans") { ShowOrphans(); } // show all the descendents of an individual else if (command == "descendants" && commandWords.Length > 1) { ListDescendants(commandWords[1]); } // find the shortest path of relationships between two people //else if (command == "bingo" && commandWords.Length > 1) //Bingo(commandWords[1], commandWords[2]); // dump command prints out the graph else if (command == "dump") { rg.dump(); } // illegal command else { Console.Write("\nLegal commands: read [filename], dump, show [personname],\n friends [personname], exit\n"); } } }