当前位置: 首页>>代码示例>>C#>>正文


C# GSM.CalculateTotalPrice方法代码示例

本文整理汇总了C#中GSM.CalculateTotalPrice方法的典型用法代码示例。如果您正苦于以下问题:C# GSM.CalculateTotalPrice方法的具体用法?C# GSM.CalculateTotalPrice怎么用?C# GSM.CalculateTotalPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GSM的用法示例。


在下文中一共展示了GSM.CalculateTotalPrice方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HistoryTest

    public void HistoryTest()
    {
        Console.WriteLine(new string('-', 50));
        Console.WriteLine("                  Calls history");
        Console.WriteLine(new string('-', 50));
        Console.WriteLine();
        GSM phone = new GSM();
        phone.AddHistory(DateTime.Now, "0891234567", 10);
        phone.AddHistory(DateTime.Now, "0883456789", 47.99);
        phone.AddHistory(DateTime.Now, "0872345678", 89.01);
        phone.PrintCalls();

        Console.WriteLine();
        Console.WriteLine("Assuming the price per minute is 0.37! Calculate the total price of the calls:");
        Console.WriteLine(new string('-', 77));
        phone.CalculateTotalPrice();
        Console.WriteLine();
        Console.WriteLine();

        Console.WriteLine("Delete longest call from the history and calculate the total price again:");
        Console.WriteLine(new string('-', 74));
        phone.DeleteHistory(89.01);
        phone.CalculateTotalPrice();
        Console.WriteLine();
        Console.WriteLine();

        Console.WriteLine(new string('-', 50));
        Console.WriteLine("           Calls history after delete");
        Console.WriteLine(new string('-', 50));
        Console.WriteLine();
        phone.ClearHistory();
        phone.CalculateTotalPrice();
    }
开发者ID:Nikolay-D,项目名称:TelerikSchoolAcademy,代码行数:33,代码来源:GSMCallHistoryTest.cs

示例2: Main

    static void Main()
    {
        GSM mobile = new GSM("3310", "Nokia");

        //Add some calls
        mobile.AddCallToHistory(new Call(DateTime.Now.AddDays(3), DateTime.Now.TimeOfDay, "0888123123", 120));
        mobile.AddCallToHistory(new Call(DateTime.Now.AddDays(5), DateTime.Now.TimeOfDay, "0888456456", 35));

        //Display call history and total price
        mobile.DisplayCallHistory();
        Console.WriteLine("Total price: {0:F2}", mobile.CalculateTotalPrice(0.37));
        Console.WriteLine();

        //Remove longest call and display total price again
        mobile.RemoveLongestCall();
        Console.WriteLine("Total price: {0:F2}", mobile.CalculateTotalPrice(0.37));
        Console.WriteLine();

        //Clear call history and print it
        mobile.ClearCallHistory();
        mobile.DisplayCallHistory();
    }
开发者ID:vanndann,项目名称:TelerikAcademy,代码行数:22,代码来源:GSMCallHistoryTest.cs

示例3: Main

        static void Main()
        {
            GSM gsm = new GSM(new Display(10, 20, 5, 20), new Battery(BatteryType.NiCd, 43, 34), "Lumia", "Nokia", 100, "Pesho");
            var someCalls = new List<Call>();
            someCalls.Add(new Call(new DateTime(2015, 3, 13, 13, 24, 45), "0889666060", 100));
            someCalls.Add(new Call(new DateTime(2015, 3, 11, 13, 4, 45), "0899606060", 2000));
            someCalls.Add(new Call(new DateTime(2015, 3, 12, 13, 2, 4), "0899606060", 130));
            someCalls.Add(new Call(new DateTime(2015, 3, 3, 13, 24, 5), "0899606060", 400));
            foreach (var call in someCalls)
            {
                gsm.AddCall(call);
            }

            foreach (var call in gsm.CallHistory)
            {
                Console.WriteLine("Date: {0}.{1}.{2} - {3}:{4}:{5}, Phone number: {6}, Duration: {7}s", call.Date.Day, call.Date.Month, call.Date.Year,
                    call.Date.Hour, call.Date.Minute, call.Date.Second, call.DilledPhoneNumber, call.DurationOfCall);
            }

            decimal  resultTotalPrice = gsm.CalculateTotalPrice(gsm.CallHistory);
            Console.WriteLine("Total price of all calls: {0:F2}", resultTotalPrice);

            int longestCall = 0;
            int indexOfLongestCall = 0;
            for(int i = 0; i < gsm.CallHistory.Count; i++)
            {
                if(gsm.CallHistory[i].DurationOfCall > longestCall)
                {
                    longestCall = gsm.CallHistory[i].DurationOfCall;
                    indexOfLongestCall = i;
                }
            }

            gsm.DeleteCall(indexOfLongestCall);
            resultTotalPrice = gsm.CalculateTotalPrice(gsm.CallHistory);
            Console.WriteLine("Total price without longest call: {0:F2}", resultTotalPrice);
            gsm.ClearCallHistory();
        }
开发者ID:TeeeeeC,项目名称:TelerikAcademy2015-2016,代码行数:38,代码来源:GSMCallHistoryTest.cs

示例4: Main

    static void Main()
    {
        //GSM Test
        //Task 7
        Console.WriteLine("Test 1:");
        GSM myGSM = new GSM("Xperia SP", "Sony");
        GSM.PrintGSMCharacteristics(myGSM);

        Console.WriteLine();
        Console.WriteLine("Test 2:");
        myGSM.Price = 330;
        myGSM.Battery.BatType = BatteryType.LiIon;
        myGSM.Battery.HoursTalk = 13;
        myGSM.Battery.Model = "AB/D-F G";
        GSM.PrintGSMCharacteristics(myGSM);

        Console.WriteLine();
        Console.WriteLine("Test 3:");
        myGSM.Display.Size = 4.3;
        myGSM.Display.NumberOfColours = 16000000;
        GSM.PrintGSMCharacteristics(myGSM);

        Console.WriteLine();
        Console.WriteLine("Test 4:");
        GSM doughtersGSM = new GSM("Desire 500", "HTC");
        doughtersGSM.Owner = "Sofi";
        doughtersGSM.Price = 230.5;
        doughtersGSM.Battery.BatType = BatteryType.NiCd;
        doughtersGSM.Battery.Model = "afaf - asfg";
        doughtersGSM.Battery.HoursTalk = 14.5;
        doughtersGSM.Battery.HoursIdle = 240;
        doughtersGSM.Display.Size = 4;
        doughtersGSM.Display.NumberOfColours = 16000000;
        GSM.PrintGSMCharacteristics(doughtersGSM);

        Console.WriteLine();
        Console.WriteLine("Test 5:");
        GSM wifeGSM = new GSM("C7", "Nokia", 350.4, "Zorka");
        wifeGSM.Display = new Display(3.6, 1000000);
        GSM.PrintGSMCharacteristics(wifeGSM);

        GSM fatherGSM = new GSM("100", "Nokia");
        fatherGSM.Battery = new Battery();

        //Task 7 - Create an array of few instances of the GSM class.
        //Display the information about the GSMs in the array.
        //Display the information about the static property IPhone4S.
        Console.WriteLine();
        Console.WriteLine("Print all GSMs from a list:");
        List<GSM> gsmList = new List<GSM> { myGSM, doughtersGSM, wifeGSM, fatherGSM };

        foreach (var item in gsmList)
        {
            GSM.PrintGSMCharacteristics(item);
            Console.WriteLine();
        }

        GSM IPhone = GSM.IPhone4S;
        GSM.PrintGSMCharacteristics(IPhone);

        //Task 12 - GSMCallHistoryTest - I decided to combine GSM Test and GSMCallHistoryTest
        Console.WriteLine();
        Console.WriteLine("Call History Test:");
        GSM testGSM = new GSM("100", "Nokia");
        Call call1 = new Call(DateTime.Now, "14:59", 132, "0888 885 654");
        Call call2 = new Call(DateTime.Now, "15:39", 112, "0888 885 456");
        Call call3 = new Call(DateTime.Now, "16:22", 32, "0888 885 564");
        Call call4 = new Call(DateTime.Now, "17:15", 12, "0888 885 444");
        Call call5 = new Call(DateTime.Now, "18:12", 145, "0888 885 444");

        testGSM.AddNewCalls(call1);
        testGSM.AddNewCalls(call2);
        testGSM.AddNewCalls(call3);
        testGSM.AddNewCalls(call4);
        testGSM.AddNewCalls(call5);

        PrintCallHistory(testGSM);

        Console.WriteLine("GSM {1} {2} - Total cost of calls-->{0:f2}", testGSM.CalculateTotalPrice(0.37),
                    testGSM.Manifacturer, testGSM.Model);

        RemoveLongestCall(testGSM);
        Console.WriteLine();

        Console.WriteLine("After deleting the longest call, total cost is {0:f2}", testGSM.CalculateTotalPrice(0.37));
        Console.WriteLine();
        testGSM.ClearCallList();
        Console.WriteLine("New call history (after clearing the list):");
        PrintCallHistory(testGSM);
    }
开发者ID:Bonevm01,项目名称:OOP_DefiningClasses1,代码行数:90,代码来源:GSMtest.cs

示例5: Main

    public static void Main()
    {
        //Creating the instance of GSM.
        Battery litiumBattery = new Battery("Normal", 123, 20.5, BatteryType.LiIon);
        Display big = new Display(8.4, 3000);
        GSM myPhone = new GSM("W595", "Sony - Erikson", 678, "Cecilia", litiumBattery, big);

        //Adding few calls.
        Call[] calls = new Call[4];
        calls[0] = new Call(DateTime.Today, DateTime.Now, "0888123456", 123);
        calls[1] = new Call(DateTime.Today, DateTime.Now, "0877123456", 45);
        calls[2] = new Call(DateTime.Today, DateTime.Now, "0899123456", 540);
        calls[3] = new Call(DateTime.Today, DateTime.Now, "0789123456", 18);
        for (int i = 0; i < calls.Length; i++)
        {
            myPhone.AddHistory(calls[i]);
        }

        //Display calls information.
        foreach (var item in myPhone.callHistory)
        {
            Console.WriteLine("Date and time: {0}, Dialed phone: {1}, Duration: {2} seconds", item.Time, item.DialedPhone, item.Duration);
            Console.WriteLine();
        }

        //Print total price.
        Console.WriteLine();
        Console.WriteLine("The total price of the calls is {0:f2}", myPhone.CalculateTotalPrice(0.37));

        //Remove longest call and calculate price again.
        int longestCallIndex = 0;
        double longestDuration = 0.0;
        for (int i = 0; i < myPhone.callHistory.Count; i++)
        {
            if (myPhone.callHistory[i].Duration > longestDuration)
            {
                longestCallIndex = i;
                longestDuration = myPhone.callHistory[i].Duration;
            }
        }
        myPhone.DeleteHistory(longestCallIndex);
        Console.WriteLine();
        Console.WriteLine("The total price of the calls is {0:f2}", myPhone.CalculateTotalPrice(0.37));

        //Clear history and print it.
        myPhone.ClearHistory();
        Console.WriteLine();
        if (myPhone.callHistory.Count > 0)
        {
            foreach (var item in myPhone.callHistory)
            {
                Console.WriteLine("Date and time: {0}, Dialed phone: {1}, Duration: {2} seconds", item.Time, item.DialedPhone, item.Duration);
                Console.WriteLine();
            }
        }
        else
        {
            Console.WriteLine("Empty");
        }

    }
开发者ID:VDGone,项目名称:TelerikAcademy-2,代码行数:61,代码来源:12.+TestCalls.cs

示例6: Main

    static void Main()
    {
        //Test task 4
        GSM iPhone = new GSM("iPhone4s", "Apple");

        //Console.WriteLine(iPhone.ToString());

        //Task 7
        GSM[] phoneStore = new GSM[]
        {
            new GSM("N95","Nokia",123, "nobody", new Battery("1200",105,43), new Display(8d,16000000)),
            new GSM("X200","Samsung"),
            new GSM("eXperia","Sony",500)
        };

        //Sell a phone to Bai Pesho
        phoneStore[0].Owner = "Bai Pesho";

           // Console.WriteLine("Phones in Store:");
        foreach (var phone in phoneStore)
        {
            //Console.WriteLine(phone);
        }

        //Console.WriteLine(GSM.IPhone4S);

        GSM workPhone = new GSM("210", "Huavei", 5, "worker");
        workPhone.MakeCall(883555555, 150);
        workPhone.MakeCall(883556555, 190);
        workPhone.MakeCall(883566645, 212);

        foreach (var call in workPhone.CallHistory)
        {
            Console.WriteLine("Call to {0},  duration: {1}",call.PhoneNumber,call.CallDuration);
        }

        //Print Total Cost
        Console.WriteLine("Total Cost: " + workPhone.CalculateTotalPrice(0.37m));

        //Find and remove longest call
        ;
        ulong maxDuration = ulong.MinValue;

        foreach (var call in workPhone.CallHistory)
        {
            if (call.CallDuration>maxDuration)
            {
                maxDuration = call.CallDuration;
            }
        }

        if (maxDuration != ulong.MinValue)
        {
            workPhone.RemoveCallByDuration(maxDuration);
            Console.WriteLine();
            Console.WriteLine("Removed call with duration: " + maxDuration);
        }

        //Print Total Cost without longest duration

        Console.WriteLine("Total Cost: " + workPhone.CalculateTotalPrice(0.37m));
        Console.WriteLine();

        foreach (var call in workPhone.CallHistory)
        {
            Console.WriteLine(call.ToString());
        }

        workPhone.ClearCallHistory();
        //Print again
        Console.WriteLine("Call History: ");
        foreach (var call in workPhone.CallHistory)
        {
            Console.WriteLine(call.ToString());
        }
        //
    }
开发者ID:nkolarov,项目名称:telerik-academy,代码行数:77,代码来源:GSMCallHistoryTest.cs


注:本文中的GSM.CalculateTotalPrice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。