Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var mobileOperator = new MobileOperator();
            var max            = new MobileAccount(093); mobileOperator.AddToBase(max);
            var crab           = new MobileAccount(050); mobileOperator.AddToBase(crab);
            var zloi           = new MobileAccount(067); mobileOperator.AddToBase(zloi);

            zloi.Call(max, "where is my money?");
            crab.SMS(zloi, "come here lazy!");
            max.SMS(crab, "let me write off your homework))");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public void ProcIncConn(MobileAccount toAcc, MobileAccount fromAcc, bool isSMS, string message)
        {
            var IsPresent = false;

            foreach (var acc in AccountsList)
            {
                if (acc.Number == toAcc.Number)
                {
                    acc.ShowOnScreen($"Subscriber '{acc.Number}' received " + (isSMS?"SMS":"call") + $" from '{fromAcc.Number}' subscriber: {message}");
                    IsPresent = true;
                    break;
                }
            }
            //if (!IsPresent)
            //    fromAcc.ShowOnScreen("There is no such accaunt");
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var mobileOperator = new MobileOperator();
            var max            = new MobileAccount("Max", 09311);
            var crab           = new MobileAccount("Ievgen", 05011);
            var zloi           = new MobileAccount("Yaroslav", 06711);
            var dima           = new MobileAccount("Dima", 06722);
            var artem          = new MobileAccount("Artem", 06733);
            var andrey         = new MobileAccount("Andrey", 09322);
            var vital          = new MobileAccount("Vitaly", 05022);

            mobileOperator.AddToBase(max);
            mobileOperator.AddToBase(crab);
            mobileOperator.AddToBase(zloi);
            mobileOperator.AddToBase(dima);
            mobileOperator.AddToBase(artem);
            mobileOperator.AddToBase(andrey);
            mobileOperator.AddToBase(vital);

            max.Call(crab, "let me write off your homework))");
            max.SMS(artem, "let me write off your homework))");
            max.Call(dima, "let me write off your homework))");
            max.SMS(artem, "let me write off your homework))");

            crab.SMS(zloi, "come here lazy!");
            crab.Call(artem, "come here lazy!");
            crab.SMS(max, "come here lazy!");
            crab.Call(dima, "come here lazy!");

            zloi.Call(max, "where is my money?");
            zloi.SMS(crab, "where is my money?");
            zloi.Call(dima, "where is my money?");
            zloi.SMS(artem, "where is my money?");
            zloi.Call(andrey, "where is my money?");
            zloi.SMS(max, "where is my money?");

            dima.Call(vital, "where is my money?");
            dima.SMS(andrey, "where is my money?");
            dima.Call(dima, "where is my money?");
            dima.SMS(artem, "where is my money?");
            dima.Call(andrey, "where is my money?");

            artem.Call(vital, "where is my money?");
            artem.SMS(andrey, "where is my money?");
            artem.Call(dima, "where is my money?");

            andrey.Call(max, "where is my money?");
            andrey.SMS(crab, "where is my money?");

            vital.Call(dima, "where is my money?");

            Console.WriteLine("\nTop 5 most wanted abonents:");
            var mostWanted = mobileOperator.CallLogList.GroupBy(i => i.Item1).Select(g => new { PhoneNumber = g.Key, Count = g.Count() }).
                             OrderByDescending(i => i.Count).Select(g => g.PhoneNumber).Take(5);

            foreach (var i in mostWanted)
            {
                Console.WriteLine(i);
            }

            Console.WriteLine("\nTop 5 most active abonents:");
            var mostActive = mobileOperator.CallLogList.GroupBy(i => i.Item2).Select(g => new { PhoneNumber = g.Key, Count = g.Count() }).
                             OrderByDescending(i => i.Count).Select(g => g.PhoneNumber).Take(5);

            foreach (var i in mostActive)
            {
                Console.WriteLine(i);
            }

            Console.ReadKey();
        }
Exemplo n.º 4
0
 public void SMS(MobileAccount toAcc, string message)
 {
     Connecting(toAcc, this, true, message);
 }
Exemplo n.º 5
0
 public void Call(MobileAccount toAcc, string message)
 {
     Connecting(toAcc, this, false, message);
 }
Exemplo n.º 6
0
 public void AddToBase(MobileAccount acc)
 {
     this.AccountsList.Add(acc);
     acc.Connecting += this.ProcIncConn;
 }