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


C# GSM.CallPrice方法代码示例

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


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

示例1: CallsInfo

    private static void CallsInfo()
    {
        // 12. Test the call history functionality of the GSM class.
        GSM gsm = new GSM("Optimus", "LG"); // 12.1 Create an instance of the GSM class.

        // 12.2 Add few calls.
        gsm.AddCall(DateTime.Now, 0871111111, 60);
        gsm.AddCall(DateTime.Now, 0882222222, 200);
        gsm.AddCall(DateTime.Now, 0893333333, 1234);

        // 12.3 Display the information about the calls.
        gsm.PrintHistory();

        /* 12.4 Assuming that the price per minute is 0.37
                Calculate and print the total price of the calls in the history. */
        Console.WriteLine("The cost of calls is: {0:C2}", gsm.CallPrice(0.37f));

        // 12.5 Remove the longest call from the history and calculate the total price again.
        gsm.DeleteCall(1234);
        Console.WriteLine("The cost of calls without the longest one is: {0:C2}", gsm.CallPrice(0.37f));

        // 12.6 Finally clear the call history and print it.
        gsm.ClearHistory();
        gsm.PrintHistory();
        Console.WriteLine("History is cleared!" + Environment.NewLine);

        Main();
    }
开发者ID:unbelt,项目名称:Telerik,代码行数:28,代码来源:GSMTest.cs

示例2: Main

 static void Main()
 {
     GSM nokia = new GSM("N7", "Nokia");
     nokia.AddCall(360);
     nokia.AddCall(500);
     nokia.AddCall(1500);
     nokia.DisplayCalls();
     Console.WriteLine("The total price of the calls with 0.37st/min is {0}", nokia.CallPrice(0.37));
     nokia.DeleteCall(1500);
     nokia.DisplayCalls();
     Console.WriteLine("The total price of the calls without the longest call is {0}", nokia.CallPrice(0.37));
 }
开发者ID:TeodorKostadinov,项目名称:TelerikOOP-1,代码行数:12,代码来源:GSMCallHistoryTest.cs

示例3: Main

    static void Main(string[] args)
    {
        GSM gsm1 = new GSM("Nokia", "Nokia Corp");
        GSM gsm2 = new GSM("Apple", "Apple Inc.");

        gsm1.Price = 1300;

        gsm1.Battery.HoursIdle = 120;
        gsm1.Battery.HoursTalk = 12;
        gsm1.TypeOfBattery = Battery.BatteryType.NiCd;
        gsm1.Battery.Model = "China";
        gsm1.Display.NumberOfColors = 16;
        gsm1.Display.Size = 4.5;
        gsm1.AddCallToHistory("26.2.2013", "12:00", 0887698631, 123);
        gsm1.AddCallToHistory("27.2.2013", "12:00", 0887698631, 123);

        gsm1.AddCallToHistory("28.2.2013", "12:00", 0887698631, 123);
        gsm1.Owner = "Pencho";

        Console.WriteLine(gsm1);

        Console.WriteLine(gsm1.CallPrice(0.45m));

        //GSM gsm2 = GSM.IPhone4S;
        //Console.WriteLine(gsm2);

        //GSMTest gsm3 = new GSMTest(5);
        //foreach (var item in gsm3)
        //{
        //    Console.WriteLine(item);
        //}
    }
开发者ID:rsmont,项目名称:OOP,代码行数:32,代码来源:Main.cs

示例4: CallHistoryTest

    //method for testing the calls
    public static void CallHistoryTest()
    {
        Console.WriteLine(new string('-', 30));
        Console.WriteLine("Phone calls test");

        //creates an instance of the GSM class
        var phone = new GSM("Lumia 1920", "Nokia");

        //adds calls
        phone.AddACall(new Call("0555 555 555", 120));
        phone.AddACall(new Call("0999 999 999", 153));
        phone.AddACall(new Call("0888 888 888", 305));

        //displays information about calls
        Console.WriteLine(new string('-', 30));
        Console.WriteLine("Calls added.");
        Console.WriteLine("Calls: ");
        foreach (var call in phone.CallHistory)
        {
            Console.WriteLine(call.ToString());
            Console.WriteLine();
        }

        //total price at 0.37 price per minute
        Console.WriteLine(new string('-', 30));
        var price = phone.CallPrice(0.37M);
        Console.WriteLine("Total price of the calls: {0:F2}", price);

        //finding longest call
        ulong longestCall = 0;
        foreach (var call in phone.CallHistory)
        {
            if (call.Duration > longestCall)
            {
                longestCall = call.Duration;
            }
        }
        Console.WriteLine(new string('-', 30));
        Console.WriteLine("Longest call: {0} seconds", longestCall);

        //removing longest call
        var longest = new Call("000", 000);
        foreach (var call in phone.CallHistory)
        {
            if (call.Duration == longestCall)
            {
                longest = call;
            }
        }
        phone.DeleteACall(longest);

        //calculate total price again
        Console.WriteLine(new string('-', 30));
        Console.WriteLine("After removing the longest call: ");
        price = phone.CallPrice(0.37M);
        Console.WriteLine("Total price of the calls: {0:F2}", price);

        //clear call history
        Console.WriteLine(new string('-', 30));
        Console.WriteLine("Clearing call history...");
        phone.ClearCallHistory();

        //print call history
        Console.WriteLine("Call history elements: {0}", phone.CallHistory.Count);
    }
开发者ID:Vyara,项目名称:Telerik-Academy,代码行数:66,代码来源:GSMCallHistoryTest.cs

示例5: Main

    static void Main()
    {
        GSM[] gsmArray = { 
                             new GSM("S3", "Galaxy", 710M, "Reni", new Battery("A12", 20, 5, BatteryType.LiIon), new Display(4.8, 50000)),
                             new GSM("5", "Nexus", 610M, "Stasko", new Battery("A13", 19, 6, BatteryType.NiCd), new Display(5, 40000)),
                         };

        foreach (var gsm in gsmArray)
        {
            Console.WriteLine(gsm.ToString());
            Console.WriteLine(new string('-', 50));
        }

        Console.WriteLine("Static property: {0}", GSM.IPhone4S);

        GSM myGSM = new GSM("Xperia", "Sony", 510M, "Didi", new Battery("A14", 15, 7, BatteryType.NiMH), new Display(4.9, 45000));


        List<Call> callHistory = new List<Call>
                            {
                               new Call(new DateTime(2015, 03, 18), new Time(23, 22, 56), "0888123456", 360),
                               new Call(new DateTime(2015, 02, 19), new Time(13, 19, 25), "0888124556", 520),
                               new Call(new DateTime(2015, 01, 15), new Time(11, 10, 20), "0888124106", 800)
                            };

        //add calls to call history list
        foreach (var call in callHistory)
        {
            myGSM.AddCall(call);
        }

        Console.WriteLine(myGSM.ToString());
        myGSM.CallHistory.Add(new Call(new DateTime(2015, 01, 15), new Time(11, 10, 20), "0888124106", 800));
        //print call history
        myGSM.PrintCallHistory();

        //calculate total price and print it
        decimal totalPrice = myGSM.CallPrice(myGSM.CallHistory, 0.37M);
        Console.WriteLine("Total call's price: {0}", totalPrice);

        //remove the longest call from the history 
        Call longestCall = new Call();
        foreach (var call in callHistory)
        {
            if (longestCall.Duration <= call.Duration)
            {
                longestCall = call;
            }
        }

        //delete longest call
        myGSM.DeleteCall(longestCall);
        myGSM.PrintCallHistory();

        //calculate the total price again
        totalPrice = myGSM.CallPrice(myGSM.CallHistory, 0.37M);
        Console.WriteLine("Total call's price: {0}", totalPrice);

        //clear the call history and print it.
        myGSM.ClearHistory();
        myGSM.PrintCallHistory();
    }
开发者ID:ReniGetskova,项目名称:CSharp-OOP,代码行数:62,代码来源:GSMtest.cs


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