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


C# GSM.TotalPrice方法代码示例

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


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

示例1: Main

    static void Main()
    {
        GSM phone1 = new GSM("Samsung", "Germany", 1000);
            GSM phone2 = new GSM("Nokia", "Italy", 200.99m, "Boris");
            GSM phone3 = GSM.IPhone4S;

            GSM[] phones = new GSM[] { phone1, phone2, phone3 };

            Call newCall1 = new Call("05.03.2013",  "0882203628", 100);
            Call newCall2 = new Call("01.02.2013", "11:00", "0882203628", 60);
            Call newCall3 = new Call("0882203628", 10);
            Call newCall4 = new Call("08.03.2013", "21:00", "0882203628", 360);

            phone1.AddCall(newCall1);
            phone1.AddCall(newCall2);
            phone1.AddCall(newCall3);
            phone1.AddCall(newCall4);

            //Print CallHistory
            StringBuilder result = new StringBuilder();
            foreach (var call in phone1.CallHistory)
            {
                result.AppendFormat("Date: {0}\nTime: {1}\nDialedNumber: {2}\nDuration (in seconds): {3}\n\n",
                    call.date, call.time, call.dialedPnoneNumber, call.duration);
            }

            Console.WriteLine(result.ToString());

            //Calculate TotalPrice
            decimal price = phone1.TotalPrice(0.37m);
            Console.WriteLine("{0:F2}лв.", price);

            //Calculate TotalPrice without long call
            phone1.DeleteCall(newCall4);
            decimal priceWithoutLongCall = phone1.TotalPrice(0.37m);
            Console.WriteLine("{0:F2}лв.", priceWithoutLongCall);

            //Clear CallHistory
            phone1.ClearCallHistory();

            StringBuilder resultClear = new StringBuilder();
            foreach (var call in phone1.CallHistory)
            {
                resultClear.AppendFormat("Date: {0}\nTime: {1}\nDialedNumber: {2}\nDuration (in seconds): {3}\n\n",
                    call.date, call.time, call.dialedPnoneNumber, call.duration);
            }
            Console.WriteLine();
            Console.WriteLine("The result after clear is: \n", resultClear.ToString());
    }
开发者ID:rumyanaaleksandrova,项目名称:Classes_1,代码行数:49,代码来源:GSMCallHistoryTest.cs

示例2: GSMCallHistoryTests

 public void GSMCallHistoryTests()
 {
     Battery battery = new Battery("BatteryModel", 50, 70, BatteryType.NiMH);
     Display display = new Display(20, 65000);
     GSM phone = new GSM("k50in", "Nokia", 999, "Petyrcho", battery, display);
     //calls
     DateTime day1 = new DateTime(2013,02,25,12,10,43);
     Call call1 = new Call(day1, "0888888888", 175);
     DateTime day2 = new DateTime(2013, 02, 25, 15, 10, 13);
     Call call2 = new Call(day2, "0888888888", 115);
     DateTime day3 = new DateTime(2013, 02, 25, 22, 18, 07);
     Call call3 = new Call(day3, "0888888888", 741);
     //Display the information about the calls.
     Console.WriteLine(call1);
     Console.WriteLine(call2);
     Console.WriteLine(call3);
     //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history
     // adding the calls in the call history
     phone.AddCalls(call1);
     phone.AddCalls(call2);
     phone.AddCalls(call3);
     // calculate the total price
     Console.Write("Total price : ");
     Console.WriteLine(phone.TotalPrice(37));
     //Remove the longest call from the history and calculate the total price again.
     Console.Write("The longest call is : ");
     Console.WriteLine(phone.LongestCall.Duration);
     //removing the longest call
     phone.DeleteCall(phone.LongestCall);
     //total price without the longest call
     Console.Write("Total price without the longest call is : ");
     Console.WriteLine(phone.TotalPrice(37));
     //Finally clear the call history and print it
     phone.ClearCallHistory();
     //print
     Console.WriteLine("History : ");
     Console.WriteLine("   " +phone.CallHistory.Count);
     //The next will be better
 }
开发者ID:naturalna,项目名称:OOPPrinciples,代码行数:39,代码来源:GSMCallHistoryTest.cs


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