本文整理汇总了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());
}
示例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
}