예제 #1
0
 public bool Equals(MobileNumber other)
 {
     if ((object)other == null)
     {
         return(false);
     }
     return(CountryCode == other.CountryCode && OperatorCode == other.OperatorCode && Number == other.Number);
 }
예제 #2
0
        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);
        }
예제 #3
0
        public string FindInPhonebook(MobileNumber number)
        {
            string checkedNumber;

            if (Phonebook.ContainsKey(number))
            {
                checkedNumber = Phonebook[number];
            }
            else
            {
                checkedNumber = number.ToString();
            }
            return(checkedNumber);
        }
예제 #4
0
 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);
     }
 }
예제 #5
0
        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);
            }
        }
예제 #6
0
 public MobileAccount(MobileNumber number)
 {
     Balance   = 0;
     Number    = number;
     Phonebook = new Dictionary <MobileNumber, string>();
 }