Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace TestExample28112021
- {
- // part 1
- class Contact
- {
- private string name;
- private int phone;
- private string city;
- // part 2
- public Contact(string name, int phone, string city)
- {
- }
- // part 3
- public bool fromCity(string city)
- {
- if (this.city == city)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- // end of class Contact
- // part 4
- public static void part4(Contact[] arr)
- {
- string cityName;
- Console.Write("Enter city name: ");
- cityName = Console.ReadLine();
- for (int i = 0; i < arr.Length; i++)
- {
- //if (arr[i].getCity() == cityName) {
- if (arr[i].fromCity(cityName) == true)
- {
- Console.WriteLine(arr[i].getName());
- }
- }
- }
- // part 5
- public staic int find(Contact[] arr, string name)
- {
- for (int i = 0; i < arr.Length; i++)
- {
- if (arr[i].getName() == name)
- {
- return arr[i].getPhone();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement