// accept, parse, and execute user commands private static void CommandLoop() { string command = ""; string[] commandWords; Console.Write("Welcome to Bruce Wayne'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(); } // Lists all the orphans in the file, and all orphans have the possibility of being batman else if (command == "orphan") { ShowOrphans(); } else if (command == "batman") { ShowOrphans(); } // illegal command else { Console.Write("\nLegal commands:\n" + " read [filename]\n" + " dump\n" + " show [personname]\n" + " friends [personname]\n" + " orphan\n" + " batman <same as orphan>\n" + " 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]); } else if (command == "friends" && commandWords.Length > 1) { ShowFriends(commandWords[1]); } else if (command == "orphans") { ShowOrphans(); } else if (command == "siblings" & commandWords.Length > 1) { ShowSiblings(commandWords[1]); } // 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"); } } }
// accept, parse, and execute user commands private static void CommandLoop() { string command = ""; string[] commandWords; Console.Write("Welcome to Dawson'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]; bool failed = false; 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(); } else if (command == "orphans") { rg.Orphans(); } else if (command == "siblings") { rg.Siblings(commandWords[1]); } else if (command == "descendants") { rg.Descendants(commandWords[1], 0, out failed); } else if (command == "bingo") { rg.Bingo(commandWords[1], commandWords[2]); } else if (command == "cousins") { if (int.TryParse(commandWords[2], out _) && int.TryParse(commandWords[3], out _)) { rg.Cousins(commandWords[1], Convert.ToInt32(commandWords[2]), Convert.ToInt32(commandWords[3])); } else { Console.Write("Invalid number"); } } // illegal command else { Console.Write("\nLegal commands: read [filename], dump, show [personname],\n friends [personname], orphans, siblings [personname], descendants [personname], bingo [personname1] [personname2] 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]); } else if (command == "friends" && commandWords.Length > 1) { ShowFriends(commandWords[1]); } // dump command prints out the graph else if (command == "dump") { rg.Dump(); } else if (command == "orphans") { ShowOrphans(); } else if (command == "bingo") { ShowBingo(commandWords[1], commandWords[2]); } else if (command == "descendants") { ShowDescendents(commandWords[1]); } else if (command == "cousins") { CousinsNK(commandWords[1], Convert.ToInt32(commandWords[2]), Convert.ToInt32(commandWords[3])); } // illegal command else { Console.Write("\nLegal commands: read [filename], dump, show [personname],\n friends [personname], " + "orphans, bingo [personname] [personname], cousins [personname] [nth cousins] [k times removed], 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 the person's friends else if (command == "friends" && commandWords.Length > 1) { ShowFriends(commandWords[1]); } // dump command prints out the graph else if (command == "dump") { rg.Dump(); } // list all the people with no parents else if (command == "orphans") { ShowOrphans(); } // find a shortest chain of relationships between two persons else if (command == "bingo" && commandWords.Length > 1) { try { if (rg.GetNode(commandWords[1]) != null && rg.GetNode(commandWords[2]) != null) { List <GraphNode> path = ShowBingo(commandWords[1], commandWords[2]); for (int i = 1; i < path.Count; i++) { foreach (GraphEdge e in path[i - 1].GetEdges()) { if (e.ToNode() == path[i]) { Console.WriteLine(path[i - 1].GetName() + " is a " + e.GetLabel().Substring(3) + " of " + path[i].GetName()); } } } } else { Console.WriteLine(commandWords[1] + " has no relation to " + commandWords[2]); } } catch (Exception e) { Console.Write("Unable to read\n"); Console.WriteLine(e.Message); } } // show all of the person's decendents else if (command == "decendents" && commandWords.Length > 1) { ShowDecendents(commandWords[1]); } // show all of the person's nth-cousins k times removed else if (command == "cousins" && commandWords.Length > 1) { try { ShowCousins(commandWords[1], Int32.Parse(commandWords[2]), Int32.Parse(commandWords[3])); } catch (Exception e) { Console.Write("Unable to read\n"); Console.WriteLine(e.Message); } } // illegal command else { Console.Write("\nLegal commands: read [filename], dump, show [personname],\n friends [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]); } else if (command == "friends" && commandWords.Length > 1) { ShowFriends(commandWords[1]); } // dump command prints out the graph else if (command == "dump") { rg.Dump(); } // orphans comand prints out all orphans else if (command == "orphans") { Orphans(); } // bingo command prints shortest connection between two people if there is one else if (command == "bingo") { Bingo(commandWords[1], commandWords[2]); } // descendants command prints the list of descendants of the given person if there are any else if (command == "descendants") { Descendants(commandWords[1]); } // illegal command else { Console.Write("\nLegal commands: read [filename], dump, show [personname],\n friends [personname], orphans, bingo [personname1] [personname2], descendants [personname], exit\n"); } } }
// accept, parse, and execute user commands private static void CommandLoop() { string command = ""; string[] commandWords; Console.Write("Welcome to Ian Christensen'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]); } else if (command == "orphans") { ShowOrphans(); } else if (command == "descendents" && commandWords.Length > 1) { ShowDescendents(commandWords[1]); } else if (command == "cousins" && commandWords.Length > 1) { ShowCousins(commandWords[1], int.Parse(commandWords[2]), int.Parse(commandWords[3])); } else if (command == "bingo" && commandWords.Length > 1) { PlayBingo(commandWords[1], commandWords[2]); } // dump command prints out the graph else if (command == "dump") { rg.Dump(); } // illegal command else { Console.Write("\nLegal commands:\nread [filename]\ndump\nshow [personname]\nfriends [personname]\norphans\ndescendents [personname]\ncousins [personname][nth degree][kth removed]\nexit\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 the whole graph else if (command == "orphans") { ShowOrphans(); } // 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]); } else if (command == "siblings" && commandWords.Length > 1) { ShowSiblings(commandWords[1]); } else if (command == "descendants" && commandWords.Length > 1) { ShowDescendants(commandWords[1]); } else if (command == "cousins" && commandWords.Length > 3) { ShowCousins(commandWords[1], int.Parse(commandWords[2]), int.Parse(commandWords[3])); } // show shortest chain between people else if (command == "bingo" && commandWords.Length > 2) { FindBingo(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], " + "friends [personname], " + "siblings [personname], " + "descendents [personname], " + "cousins [personname] [numCousin] [numTimesRemoved], " + "exit\n"); } } }