本文整理汇总了C#中GSM.RemoveCall方法的典型用法代码示例。如果您正苦于以下问题:C# GSM.RemoveCall方法的具体用法?C# GSM.RemoveCall怎么用?C# GSM.RemoveCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GSM
的用法示例。
在下文中一共展示了GSM.RemoveCall方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
GSM gsm = new GSM("Galaxy S3", "Samsung");
gsm.AddCall(new Call(DateTime.Now, "5551337", 150));
gsm.AddCall(new Call(DateTime.Now.AddDays(-1), "5551337", 230));
gsm.AddCall(new Call(new DateTime(2013, 2, 19), "5551337", 420));
foreach (var call in gsm.CallHistory)
{
Console.WriteLine(call);
}
Console.WriteLine("{0:C}", gsm.CalculateCallsPrice(0.37M));
//get the longest call;
Call maxCall = gsm.CallHistory.Where(x => x.Duration == gsm.CallHistory.Max(y => y.Duration)).Single();
//remove the longest call from the call history
gsm.RemoveCall(maxCall);
//print the total price without the longest call
Console.WriteLine("{0:C}", gsm.CalculateCallsPrice(0.37M));
gsm.ClearCallHistory();
foreach (var call in gsm.CallHistory)
{
Console.WriteLine(call);
}
}
示例2: Main
static void Main()
{
System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
GSM gsm = new GSM("Galaxy S3", "Samsung");
gsm.AddCall(846022, 150);
gsm.AddCall(35956, 132);
gsm.PrintCalls();
Console.WriteLine("-------------");
gsm.RemoveCall(35956);
gsm.PrintCalls();
Console.WriteLine("-------------");
gsm.AddCall(654213, 32);
gsm.ClearHistory();
gsm.PrintCalls();
}
示例3: Test
public static void Test()
{
//Create Instance of GSM
GSM myMobile = new GSM("One", "HTC", 1240, "Pratchett, Terry",
new Display(720, 1280, 4.5, 64000000),
new Battery("2070 mAh", 300, 150, Battery.BatteryTypes.LiIon)
);
//Add some calls to CallHistory
Call callOne = new Call(DateTime.Now, "+898 888 888", 1204);
Call callTwo = new Call(DateTime.Now.AddDays(1), "+888 888 898", 1024);
Call callThree = new Call(DateTime.Now.AddDays(1), "+888 888 898", 200);
Call callFour = new Call(DateTime.Now.AddHours(1), "+888 898 898", 2020);
myMobile.CallHistory.Add(callOne);
myMobile.CallHistory.Add(callTwo);
myMobile.CallHistory.Add(callThree);
myMobile.CallHistory.Add(callFour);
//Display the information about the calls
Console.WriteLine("All calls information\n");
foreach (Call item in myMobile.CallHistory)
{
Console.WriteLine(item);
}
//Assuming that the price per minute is 0.37 calculate and print
//the total price of the calls in the history.
Console.WriteLine("Calculate price example: ");
var pricePerMinute = 0.37m;
Console.WriteLine("Price of all calls {0:c}", myMobile.CallculatePrice(pricePerMinute));
//Remove the longest call from the history and calculate the total price again.
//find the longest call
Call longestCall = FindLongestCall(myMobile);
//remove the longest call
myMobile.RemoveCall(longestCall);
//calculate the price again and print it
Console.WriteLine("Price after removing longest call: {0:c}", myMobile.CallculatePrice(pricePerMinute));
//Finally clear the call history and print it.
Console.WriteLine("\nBefore clear call history stores {0} items", myMobile.CallHistory.Count);
myMobile.ClearCallHistory();
Console.WriteLine("Now call history stores {0} items", myMobile.CallHistory.Count);
}
示例4: Main
static void Main()
{
Battery newBattery = new Battery(BatteryType.LiIon, "ChinaBattery", 10, 10);
Display newDisplay = new Display(4.0, 16000000);
GSM[] gsms = new GSM[2];
gsms[0] = new GSM("iPhone5", "Apple", 1500, "Steve Jobs", newBattery, newDisplay);
gsms[1] = new GSM("Galaxy Ace", "Samsung", 500, "Lee Byung-chull", newBattery, newDisplay);
Console.WriteLine(gsms[0]);
Console.WriteLine(gsms[1]);
Console.WriteLine("Iphone Model: {0}", GSM.IPhone4S.Model);
Console.WriteLine("Iphone Manufacturer: {0}", GSM.IPhone4S.Manufacturer);
Console.WriteLine("Iphone Price: {0}", GSM.IPhone4S.Price);
//Task 12
Console.WriteLine();
Console.WriteLine("---------------------------------------");
Console.WriteLine();
GSM nokiaPhone = new GSM("C6-01", "Nokia", 400, "Nokia owner", newBattery, newDisplay);
nokiaPhone.AddCall(DateTime.Now, 359888123456, 120);
nokiaPhone.AddCall(DateTime.Now, 359884000000, 240);
nokiaPhone.AddCall(DateTime.Now, 359882000000, 480);
int longestCall = 0;
int longestDuration = 0;
for (int i = 0; i < nokiaPhone.CallHistory.Count; i++)
{
if (nokiaPhone.CallHistory[i].DurationInSeconds > longestDuration)
{
longestDuration = nokiaPhone.CallHistory[i].DurationInSeconds;
longestCall = i;
}
Console.WriteLine("Call from {0} to {1} lasted {2} seconds", nokiaPhone.CallHistory[i].Date, nokiaPhone.CallHistory[i].DialedPhoneNumber, nokiaPhone.CallHistory[i].DurationInSeconds);
}
Console.WriteLine();
Console.WriteLine("Total calls cost is {0}lv.", nokiaPhone.TotalCallPrice(0.37));
nokiaPhone.RemoveCall(longestCall);
Console.WriteLine("Total calls cost after deleting the longest call is {0}lv.", nokiaPhone.TotalCallPrice(0.37));
nokiaPhone.ClearCalls();
}
示例5: Main
static void Main()
{
GSM[] tests = new GSM[3];
GSM cellPhone1 = new GSM("Desire X", "HTC", "HTC Store", 499.99M);
tests[0] = cellPhone1;
GSM cellPhone2 = new GSM("Lumia 810", "Nokia");
cellPhone2.Price = 499.99M;
cellPhone2.Owner = "OVI Store";
cellPhone2.battery.Type = BatteryType.Li_Ion;
tests[1] = cellPhone2;
GSM cellPhone3 = GSM.iPhone;
tests[2] = cellPhone3;
foreach (var item in tests)
{
Console.WriteLine(item);
}
cellPhone1.AddCall(DateTime.Now, "0897789987", 230);
cellPhone1.CalcPrice(0.32M);
cellPhone1.RemoveCall();
cellPhone1.ClearHistory();
}
示例6: Main
static void Main()
{
// just some sample tests
GSM tel = new GSM("Nokia", "gosho tupoto", owner: "Pesho");
tel.AddCall("0885032502", new DateTime(2003, 2, 1), new TimeSpan(0, 10, 15));
tel.AddCall("0883456782", new DateTime(2003, 2, 1), new TimeSpan(0, 20, 15));
tel.AddCall("+359885032548", new DateTime(2003, 2, 1), new TimeSpan(0, 10, 15));
tel.AddCall("+359885032576", new DateTime(2003, 2, 1), new TimeSpan(0, 15, 15));
Console.WriteLine(tel.GetCost(0.37));
tel.RemoveCall();
tel.PrintHistory();
Console.WriteLine(tel.GetCost(0.37));
tel.ClearHistory();
tel.PrintHistory();
Console.WriteLine(tel + "\n\n\n");
// IPhone test
Console.WriteLine(GSM.IPhone4S);
}
示例7: Main
static void Main(string[] args)
{
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
GSM NokiaGSM = new GSM("N-30", "Nokia", 180m, new Person("Gogo"), new Battery("825L", 123, 100, BatteryType.LiIon), new Display(15, 1024));
NokiaGSM.AddCall(new Call(DateTime.Now, "088888888", 156));
NokiaGSM.AddCall(new Call(DateTime.Now.AddDays(3), "0888888899", 12));
NokiaGSM.AddCall(new Call(DateTime.Now.AddHours(1), "0888888344", 100));
NokiaGSM.AddCall(new Call(DateTime.Now.AddHours(56), "088883443", 1500));
decimal maxDuration = NokiaGSM.CallHistory[0].DurationInSeconds;
int positionMaxDurationCall = 0;
for (int i = 0; i < NokiaGSM.CallHistory.Count; i++)
{
Console.WriteLine("{0} call {1}", i + 1, NokiaGSM.CallHistory[i]);
Console.WriteLine();
if (NokiaGSM.CallHistory[i].DurationInSeconds > maxDuration)
{
maxDuration = NokiaGSM.CallHistory[i].DurationInSeconds;
positionMaxDurationCall = i;
}
}
Console.WriteLine(new string('-', 50));
Console.Write("The total price of your {0} calls is: ", NokiaGSM.CallHistory.Count);
Console.WriteLine(NokiaGSM.CalculatePrice(0.37m));
NokiaGSM.RemoveCall(NokiaGSM.CallHistory[positionMaxDurationCall]);
Console.Write("The total price of your {0} calls without the longest one is: ", NokiaGSM.CallHistory.Count);
Console.WriteLine(NokiaGSM.CalculatePrice(0.37m));
NokiaGSM.ClearHistory(NokiaGSM.CallHistory);
Console.Write("After clearing the history, there are {0} calls.", NokiaGSM.CallHistory.Count);
Console.WriteLine();
}