static void Main(string[] args) { Contact owner = new Contact("wppUcu", "+14155238886", ""); // Crear el contacto dueño Phonebook book = new Phonebook(owner); // Crear la lista de contactos book.Add("paolo", "+59892370344", "1174842747842416640"); book.Add("santiago", "+59898437684", ""); book.Add("seba", "+59898396922", "1175133180854243328"); // Agregar contactos a la lista // Enviar un correo a algunos contactos List <Contact> ContactsBook = book.Search(new string [] { "paolo" }); foreach (Contact contacts in ContactsBook) { book.SendWPPMessage(contacts, "hola bro"); book.SendTwitterMessage(contacts, "hola bro"); } // Enviar un WhatsApp a algunos contactos // Enviar un mensaje en Twitter }
static void Main(string[] args) { Phonebook phonebook = new Phonebook(); using (StreamReader inputReader = new StreamReader("phones.txt")) { String line = inputReader.ReadLine(); while (line != null) { string[] lineWords = line.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); string names = lineWords[0].Trim(); string town = lineWords[1].Trim(); string phone = lineWords[2].Trim(); PhoneRecord record = new PhoneRecord(names, town, phone); phonebook.Add(record); line = inputReader.ReadLine(); } } using (StreamReader inputReader = new StreamReader("commands.txt")) { String line = inputReader.ReadLine(); while (line != null) { string[] comandParameters = line.Split(new string[] { "find(", ")", ",", " " }, StringSplitOptions.RemoveEmptyEntries); List <PhoneRecord> results; if (comandParameters.Length == 2) { string names = comandParameters[0].Trim(); string town = comandParameters[1].Trim(); results = phonebook.Find(names, town); } else { string names = comandParameters[0].Trim(); results = phonebook.Find(names); } Console.WriteLine(new String('*', 30)); Console.WriteLine("Result from command {0}", line); PrintPhoneRecordList(results); line = inputReader.ReadLine(); } } }
public static void Main() { var phoneBook = new Phonebook <string, string>(); string input; while ((input = Console.ReadLine()) != "search") { var tokens = input.Split('-'); var name = tokens[0]; var phoneNumber = tokens[1]; phoneBook.Add(name, phoneNumber); } while ((input = Console.ReadLine()) != "end") { Console.WriteLine(phoneBook.Contains(input) ? $"{input} -> {phoneBook[input]}" : $"Contact {input} does not exist."); } }
public static void Main() { var allContacts = File.ReadAllLines(phonesPath); var commands = File.ReadAllLines(commandsPath); var phonebook = new Phonebook(); foreach (var line in allContacts) { phonebook.Add(line); } foreach (var command in commands) { Console.WriteLine("Current command " + command); var checkCommand = command.IndexOf("find", StringComparison.InvariantCultureIgnoreCase); if (checkCommand < 0) { Console.WriteLine("Invalid command!"); continue; } if (command.IndexOf(", ", StringComparison.InvariantCultureIgnoreCase) < 0) { var name = command.Substring(checkCommand + 4).Trim(new[] { '(', ')' }); Console.WriteLine(string.Join(Environment.NewLine, phonebook.Find(name))); } else { var nameAndTown = command.Substring(checkCommand + 4).Trim(new[] { '(', ')' }).Split(',').Select(x => x.Trim()).ToList(); Console.WriteLine(string.Join(Environment.NewLine, phonebook.Find(nameAndTown[0], nameAndTown[1]))); } Console.WriteLine(new string('-', 50)); } }