mmayoub

תרגילי חזרה, שאלה 2

Nov 28th, 2021
740
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace TestExample28112021
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             PhoneBook book;
  10.             book = new PhoneBook();
  11.  
  12.             for (int i = 0; i < 15; i++)
  13.             {
  14.                 string name, city;
  15.                 int phone;
  16.  
  17.                 Console.Write("enter contact name: ");
  18.                 name = Console.ReadLine();
  19.                 Console.Write("enter contact city: ");
  20.                 city = Console.ReadLine();
  21.                 Console.Write("enter contact phone: ");
  22.                 phone = Convert.ToInt32(Console.ReadLine());
  23.                 //phone = int.Parse(Console.ReadLine());
  24.  
  25.                 Contact contact = new Contact(name, phone, city);
  26.                 book.add(contact);
  27.             }
  28.             Console.WriteLine("Number of contacts from haifa is {0}", book.count("Haifa"));
  29.         }
  30.     }
  31. }
  32.  
RAW Paste Data