Exemplo n.º 1
0
        public void AddCall(MobileAccount calledNumber)
        {
            this.Rating++;
            var callInfo = new MobileInfo(calledNumber.uniqueNumber);

            this.CallsList.Add(callInfo);
        }
Exemplo n.º 2
0
        public void AddSms(MobileAccount smsAchiever)
        {
            this.Rating = this.Rating + 0.5;
            var smsInfo = new MobileInfo(smsAchiever.uniqueNumber);

            this.SmsList.Add(smsInfo);
        }
Exemplo n.º 3
0
 public void NotifyMakeCall(MobileAccount eventParameter)
 {
     if (makeCallEvent != null)
     {
         makeCallEvent(this, eventParameter);
     }
 }
Exemplo n.º 4
0
        public void AddAccount(MobileAccount newAccount)
        {
            this.RegisteredAccounts.Add(newAccount);
            Console.WriteLine(newAccount.uniqueNumber);

            ObserveCallsAndSms();
        }
Exemplo n.º 5
0
 public void NotifySendSms(MobileAccount eventParameter)
 {
     if (sendSMSEvent != null)
     {
         sendSMSEvent(this, eventParameter);
     }
 }
Exemplo n.º 6
0
        private void SetAdditionalSMSInfo(MobileAccount sender, MobileAccount owner)
        {
            var index = this.InfoAboutAccounts.FindIndex(o => o.ConnectedAccount == owner);

            this.InfoAboutAccounts[index].SetGetCallRatingBySMS(owner);

            var senderIndex = this.InfoAboutAccounts.FindIndex(o => o.ConnectedAccount == sender);

            this.InfoAboutAccounts[senderIndex].AddSms(owner);
        }
Exemplo n.º 7
0
        private void SetAdditionalCallInfo(MobileAccount caller, MobileAccount owner)
        {
            var index = this.InfoAboutAccounts.FindIndex(o => o.ConnectedAccount.uniqueNumber == owner.uniqueNumber);

            this.InfoAboutAccounts[index].SetGetCalledRating(owner);

            var callerIndex = this.InfoAboutAccounts.FindIndex(o => o.ConnectedAccount.uniqueNumber == caller.uniqueNumber);

            this.InfoAboutAccounts[callerIndex].AddCall(owner);
        }
Exemplo n.º 8
0
        public MobileOperator()
        {
            RegisteredAccounts = new List <MobileAccount>();
            var newAccount = new MobileAccount(random.Next(1111111, 9999999));

            Console.WriteLine(newAccount.uniqueNumber);
            RegisteredAccounts.Add(newAccount);

            ObserveCallsAndSms();
        }
Exemplo n.º 9
0
 public bool NumberExist(MobileAccount checkNumber)
 {
     foreach (MobileAccount ma in RegisteredAccounts)
     {
         if (checkNumber.uniqueNumber.Equals(ma.uniqueNumber))
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 10
0
        public void AddFriend(MobileAccount friendMobile, string friendName)
        {
            if (this.IsExist(friendMobile))
            {
                Console.WriteLine("Friend already exist");
            }
            else
            {
                friendMobile.Name = friendName;

                Friends.Add(friendMobile);
                Console.WriteLine("\nAdding Friend to {0} : \nFriend was added, name: {1}, number: {2} \n", this.uniqueNumber, friendMobile.Name, friendMobile.uniqueNumber);
            }
        }
Exemplo n.º 11
0
        private void ReceiveSms(object sender, MobileAccount mobileAcc)
        {
            var senderAcc = (MobileAccount)sender;

            if (mobileAcc.IsExist(senderAcc))
            {
                var name = mobileAcc.GetFriendName(senderAcc.uniqueNumber);
                Console.WriteLine("Your friend - {0} is sending sms", name);
            }
            else
            {
                Console.WriteLine("Receive SMS from {0} to {1} ", senderAcc.uniqueNumber, mobileAcc.uniqueNumber);
            }
        }
Exemplo n.º 12
0
        private void ReceiveCall(object sender, MobileAccount mobileAcc)
        {
            var senderAcc = (MobileAccount)sender;

            if (mobileAcc.IsExist(senderAcc))
            {
                var name = mobileAcc.GetFriendName(senderAcc.uniqueNumber);
                Console.WriteLine("Your friend - {0} is calling", name);
            }
            else
            {
                Console.WriteLine("Receive Call from {0} to {1} ", senderAcc.uniqueNumber, mobileAcc.uniqueNumber);
            }
            SetAdditionalCallInfo(senderAcc, mobileAcc);
        }
Exemplo n.º 13
0
        private MobileOperator()
        {
            RegisteredAccounts = new List <MobileAccount>();
            InfoAboutAccounts  = new List <AccountInfo>();

            var newAccount     = new MobileAccount(GetRandomNumber());
            var newAccountInfo = new AccountInfo(newAccount);

            Console.WriteLine(newAccount.uniqueNumber);

            RegisteredAccounts.Add(newAccount);
            InfoAboutAccounts.Add(newAccountInfo);

            ObserveCallsAndSms();
        }
Exemplo n.º 14
0
        public void CreateNumber()
        {
            var newAccount = new MobileAccount(random.Next(1111111, 9999999));

            if (this.NumberExist(newAccount))
            {
                Console.WriteLine("Number already exist");
            }
            else
            {
                Console.WriteLine(newAccount.uniqueNumber);
                RegisteredAccounts.Add(newAccount);

                ObserveCallsAndSms();
            }
        }
Exemplo n.º 15
0
        public void CreateNumber()
        {
            var newAccount = new MobileAccount(GetRandomNumber());

            if (this.NumberExist(newAccount))
            {
                Console.WriteLine("Number already exist");
            }
            else
            {
                Console.WriteLine(newAccount.uniqueNumber);
                this.RegisteredAccounts.Add(newAccount);

                var newAccountInfo = new AccountInfo(newAccount);
                this.InfoAboutAccounts.Add(newAccountInfo);

                ObserveCallsAndSms();
            }
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            var MobOperator = new MobileOperator();

            var simpleAcc = new MobileAccount(1111111);

            MobOperator.AddAccount(simpleAcc); // [1]

            MobOperator.CreateNumber();        // [2]
            MobOperator.RegisteredAccounts[2].AddFriend(simpleAcc, "Chernytsyn Vladyslav");

            MobOperator.CreateNumber();
            MobOperator.CreateNumber();

            MobOperator.RegisteredAccounts[0].MakeCall(MobOperator.RegisteredAccounts[1]); // simple call

            MobOperator.RegisteredAccounts[1].SendSms(MobOperator.RegisteredAccounts[2]);  // sms from friend
            MobOperator.RegisteredAccounts[1].MakeCall(MobOperator.RegisteredAccounts[2]); // call from friend

            Console.ReadLine();
        }
Exemplo n.º 17
0
 public void SendSms(MobileAccount mobileAcc)
 {
     NotifySendSms(mobileAcc);
 }
Exemplo n.º 18
0
 public FriendInfo(MobileAccount mobAcc, string name)
 {
     this.Number = mobAcc.uniqueNumber;
     this.Name   = name;
 }
Exemplo n.º 19
0
 public void MakeCall(MobileAccount mobileAcc)
 {
     NotifyMakeCall(mobileAcc);
 }
Exemplo n.º 20
0
 public AccountInfo(MobileAccount ownerAcc)
 {
     this.Rating           = 0.0;
     this.GetCalledRating  = 0.0;
     this.ConnectedAccount = ownerAcc;
 }
Exemplo n.º 21
0
 public void SetGetCalledRating(MobileAccount caller)
 {
     this.GetCalledRating++;
 }
Exemplo n.º 22
0
        public bool IsExist(MobileAccount mobileAcc)
        {
            bool isExist = this.Friends.Any(friend => friend.uniqueNumber == mobileAcc.uniqueNumber);

            return(isExist);
        }
Exemplo n.º 23
0
 public void SetGetCallRatingBySMS(MobileAccount sender)
 {
     this.GetCalledRating = this.GetCalledRating + 0.5;
 }