Exemple #1
0
        static void Main(string[] args)
        {
            IATE           aTEx   = new ATE();
            IBillingSystem bs     = new BillingSys(aTEx);
            IReportCreator report = new ReportCreator();

            IContract con1 = aTEx.RegisterContract(new User("Anton", "Goncharuk"), TypeOffTariffPlan.Business);
            IContract con2 = aTEx.RegisterContract(new User("Olga", "Gordeeva"), TypeOffTariffPlan.Smart);
            IContract con3 = aTEx.RegisterContract(new User("Alex", "Kulesh"), TypeOffTariffPlan.SmartUnlim);
            IContract con4 = aTEx.RegisterContract(new User("Misha", "Antonov"), TypeOffTariffPlan.SmartMini);

            Console.WriteLine(new string('=', 75));
            Console.WriteLine("Abonents: =>");
            Console.WriteLine(con1.User.FirstName + "  " + con1.User.LastName + "  " + con1.Number + " " + con1.Tariff.TypeOffTariffPlan + "  " + con1.User.Money);
            Console.WriteLine(con2.User.FirstName + "  " + con2.User.LastName + "  " + con2.Number + " " + con2.Tariff.TypeOffTariffPlan + "  " + con2.User.Money);
            Console.WriteLine(con3.User.FirstName + "  " + con3.User.LastName + "  " + con3.Number + " " + con3.Tariff.TypeOffTariffPlan + "  " + con3.User.Money);
            Console.WriteLine(con4.User.FirstName + "  " + con4.User.LastName + "  " + con4.Number + " " + con4.Tariff.TypeOffTariffPlan + "  " + con4.User.Money);
            Console.WriteLine(new string('=', 75));

            con4.ChangeTariff(TypeOffTariffPlan.Business);
            Console.WriteLine(new string('=', 75));

            var ter1 = aTEx.NewTerminal(con1);
            var ter2 = aTEx.NewTerminal(con2);
            var ter3 = aTEx.NewTerminal(con3);
            var ter4 = aTEx.NewTerminal(con4);

            ter1.ConnectToPort();
            ter2.ConnectToPort();
            ter3.ConnectToPort();
            ter4.ConnectToPort();

            ter1.Call(ter2.Number);
            ter3.Call(ter1.Number);
            //ter4.DisconnectFromPort();
            ter1.Call(ter4.Number);

            Console.WriteLine(new string('=', 75));
            Console.WriteLine("Report by number: {0}", ter1.Number);
            report.Create(bs.GetReport(ter1.Number), TypeOfSort.SortByDate);
            Console.WriteLine(new string('=', 75));
            //report.Create(bs.GetReport(ter1.Number), TypeOfSort.SortByCallType);
            //Console.WriteLine(new string('=', 75));
            //report.Create(bs.GetReport(ter1.Number), TypeOfSort.SortByNumber);
            //Console.WriteLine(new string('=', 75));
            //report.Create(bs.GetReport(ter1.Number), TypeOfSort.SortByCost);
            //Console.WriteLine(new string('=', 75));

            //Console.WriteLine(con1.User.FirstName + "  " + con1.User.LastName + "  " + con1.Number + " " + con1.Tariff.TypeOffTariffPlan + "  " + con1.User.Money);
            //Console.WriteLine(con2.User.FirstName + "  " + con2.User.LastName + "  " + con2.Number + " " + con2.Tariff.TypeOffTariffPlan + "  " + con2.User.Money);
            //Console.WriteLine(con3.User.FirstName + "  " + con3.User.LastName + "  " + con3.Number + " " + con3.Tariff.TypeOffTariffPlan + "  " + con3.User.Money);
            //Console.WriteLine(con4.User.FirstName + "  " + con4.User.LastName + "  " + con4.Number + " " + con4.Tariff.TypeOffTariffPlan + "  " + con4.User.Money);
            //Console.WriteLine(new string('=', 75));
        }
Exemple #2
0
        static void Main(string[] args)
        {
            IATE          ate    = new ATE();
            IReportRender render = new ReportRender();
            BillingSystem bs     = new BillingSystem(ate);

            IContract c1 = ate.RegisterContract(new Subscriber("John", "Smith"), TariffType.Pro);
            IContract c2 = ate.RegisterContract(new Subscriber("James", "Bond"), TariffType.Pro);
            IContract c3 = ate.RegisterContract(new Subscriber("Jansen", "Born"), TariffType.Pro);

            c1.Subscriber.AddMoney(10);

            var t1 = ate.GetNewTerminal(c1);
            var t2 = ate.GetNewTerminal(c2);
            var t3 = ate.GetNewTerminal(c3);

            t1.ConnectToPort();
            t2.ConnectToPort();
            t3.ConnectToPort();

            t1.Call(t2.TelephoneNumber);
            Thread.Sleep(2000);
            t2.EndCall();
            t3.Call(t1.TelephoneNumber);
            Thread.Sleep(1000);
            t3.EndCall();
            t2.Call(t1.TelephoneNumber);
            Thread.Sleep(3000);
            t1.EndCall();

            t1.Disconnect();
            t2.Disconnect();
            t3.Disconnect();

            t3.Call(t1.TelephoneNumber);

            Console.WriteLine();
            Console.WriteLine("Sorted records:");
            foreach (var item in render.SortCalls(bs.GetReport(t1.TelephoneNumber), TypeSort.SortByCallType))
            {
                Console.WriteLine(
                    "Calls:\n Type {0} |\n Date: {1} |\n Duration: {2:mm:ss} | Cost: {3} | Telephone number: {4}",
                    item.CallType,
                    item.Date,
                    item.Time,
                    item.Cost,
                    item.Number);
            }

            Console.ReadKey();
        }