本文整理汇总了C#中GSM.DeleteACall方法的典型用法代码示例。如果您正苦于以下问题:C# GSM.DeleteACall方法的具体用法?C# GSM.DeleteACall怎么用?C# GSM.DeleteACall使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GSM
的用法示例。
在下文中一共展示了GSM.DeleteACall方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}