public static void Main(string[] args) { PhoneBookManager pbm = new PhoneBookManager(); int numberOfQueries = Convert.ToInt32(Console.ReadLine()); List <string> queries = new List <string>(); for (int i = 0; i < numberOfQueries; i++) { string tempQuery = Console.ReadLine(); queries.Add(tempQuery); } for (int i = 0; i < queries.Count; i++) { string[] query = queries[i].Split(' '); string action = query[0]; if (action == "add") { string number = query[1]; string name = query[2]; pbm.AddEntry(name, number); } else if (action == "find") { string number = query[1]; string nameVal = pbm.FindNumber(number); Console.WriteLine(nameVal); } else if (action == "del") { string number = query[1]; pbm.DeleteEntry(number); } } }
private static void Main() { string phoneBookFilePath = "../../Resources/phones.txt"; string commandsFilePath = "../../Resources/commands.txt"; IEntriesManager entriesManager = new PhoneBookManager(phoneBookFilePath); CommandProcessor commandProcessor = new CommandProcessor(entriesManager); using (StreamReader reader = new StreamReader(commandsFilePath)) { string line; StringBuilder result = new StringBuilder(); while ((line = reader.ReadLine()) != null) { Command command = Command.Parse(line); string output = commandProcessor.Process(command); result.Append(output); } Console.Write(result); } }