public bool Equals(MobileNumber other) { if ((object)other == null) { return(false); } return(CountryCode == other.CountryCode && OperatorCode == other.OperatorCode && Number == other.Number); }
public override bool Equals(object obj) { if (obj == null) { return(false); } MobileNumber num = obj as MobileNumber; if ((object)num == null) { return(false); } return(CountryCode == num.CountryCode && OperatorCode == num.OperatorCode && Number == num.Number); }
public string FindInPhonebook(MobileNumber number) { string checkedNumber; if (Phonebook.ContainsKey(number)) { checkedNumber = Phonebook[number]; } else { checkedNumber = number.ToString(); } return(checkedNumber); }
public void SaveNumber(MobileNumber number, string name) { if (Phonebook.ContainsKey(number) == false) { Phonebook.Add(number, name); Console.WriteLine("{0} is saved as {1}", number, name); } else { var previousName = Phonebook[number]; Phonebook[number] = name; Console.WriteLine("{0} formerly known as {1} is overwritten as {2}", number, previousName, name); } }
public NumbersFactory(int size) { AvailableNumbers = new List <MobileNumber>(); var random = new Random(); for (var i = 0; i < size; i++) { var numberBuilder = string.Empty; for (var j = 0; j < 7; j++) { numberBuilder += random.Next(0, 10); } var newNumber = new MobileNumber(CountryCode, OperatorCode, numberBuilder); AvailableNumbers.Add(newNumber); } }
public MobileAccount(MobileNumber number) { Balance = 0; Number = number; Phonebook = new Dictionary <MobileNumber, string>(); }