本文整理汇总了C#中GSM.PrintCallHistory方法的典型用法代码示例。如果您正苦于以下问题:C# GSM.PrintCallHistory方法的具体用法?C# GSM.PrintCallHistory怎么用?C# GSM.PrintCallHistory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GSM
的用法示例。
在下文中一共展示了GSM.PrintCallHistory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
// Create an instance of the GSM class
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-GB");
Display display = new Display(2.5F, "256K");
Battery battery = new Battery(950, 35, BatteryType.LiIon);
GSM gsmTest = new GSM("Samsung Ace", "Samsung Group", 545.00M, "Ivan Ivanov", battery, display);
//Add few calls
DateTime date = DateTime.Now;
gsmTest.AddCallInHistory(date, "0889909988", 65);
gsmTest.AddCallInHistory(date.AddHours(1), "0889969988", 25);
gsmTest.AddCallInHistory(date.AddHours(2), "0883909988", 3600);
gsmTest.AddCallInHistory(date.AddHours(6.5), "0889969988", 1000);
//Display the information about the calls.
Console.WriteLine("Print the call hisory of phone {0}", gsmTest.ModelOfGSM);
Console.WriteLine(gsmTest.PrintCallHistory());
//Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history
//use readonly modificator about pricePerminute
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Total price of calls is: {0}", gsmTest.CalcucateTotalPrice(0.37M));
Console.ForegroundColor = ConsoleColor.Gray;
//Remove the longest call from the history and calculate the total price again.
gsmTest.RemoveCallByLongestDuration();
Console.WriteLine(gsmTest.PrintCallHistory());
//Finally clear the call history and print it.
gsmTest.ClearCallHistory();
Console.WriteLine(gsmTest.PrintCallHistory());
}
示例2: 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();
}