本文整理汇总了C#中GSM.ClearHistory方法的典型用法代码示例。如果您正苦于以下问题:C# GSM.ClearHistory方法的具体用法?C# GSM.ClearHistory怎么用?C# GSM.ClearHistory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GSM
的用法示例。
在下文中一共展示了GSM.ClearHistory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CallsInfo
private static void CallsInfo()
{
// 12. Test the call history functionality of the GSM class.
GSM gsm = new GSM("Optimus", "LG"); // 12.1 Create an instance of the GSM class.
// 12.2 Add few calls.
gsm.AddCall(DateTime.Now, 0871111111, 60);
gsm.AddCall(DateTime.Now, 0882222222, 200);
gsm.AddCall(DateTime.Now, 0893333333, 1234);
// 12.3 Display the information about the calls.
gsm.PrintHistory();
/* 12.4 Assuming that the price per minute is 0.37
Calculate and print the total price of the calls in the history. */
Console.WriteLine("The cost of calls is: {0:C2}", gsm.CallPrice(0.37f));
// 12.5 Remove the longest call from the history and calculate the total price again.
gsm.DeleteCall(1234);
Console.WriteLine("The cost of calls without the longest one is: {0:C2}", gsm.CallPrice(0.37f));
// 12.6 Finally clear the call history and print it.
gsm.ClearHistory();
gsm.PrintHistory();
Console.WriteLine("History is cleared!" + Environment.NewLine);
Main();
}
示例2: HistoryTest
public void HistoryTest()
{
Console.WriteLine(new string('-', 50));
Console.WriteLine(" Calls history");
Console.WriteLine(new string('-', 50));
Console.WriteLine();
GSM phone = new GSM();
phone.AddHistory(DateTime.Now, "0891234567", 10);
phone.AddHistory(DateTime.Now, "0883456789", 47.99);
phone.AddHistory(DateTime.Now, "0872345678", 89.01);
phone.PrintCalls();
Console.WriteLine();
Console.WriteLine("Assuming the price per minute is 0.37! Calculate the total price of the calls:");
Console.WriteLine(new string('-', 77));
phone.CalculateTotalPrice();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Delete longest call from the history and calculate the total price again:");
Console.WriteLine(new string('-', 74));
phone.DeleteHistory(89.01);
phone.CalculateTotalPrice();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine(new string('-', 50));
Console.WriteLine(" Calls history after delete");
Console.WriteLine(new string('-', 50));
Console.WriteLine();
phone.ClearHistory();
phone.CalculateTotalPrice();
}
示例3: RunTest
public static void RunTest()
{
GSM myPhone = new GSM("HTC Desire", "HTC", 550, "Pesho", new Battery(BatteryType.LiIon), new Display(4, 250000));
myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(5), "0887776987");
myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(8), "0897556644");
myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(15), "0887441100");
myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(23), "0885001122");
myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(4), "0896559988");
Console.WriteLine(myPhone);
Console.WriteLine("-----------Call History-----------");
foreach (Call call in myPhone.CallHistory)
{
Console.WriteLine(call);
}
Console.WriteLine("Total price of all calls: ${0:F2}", myPhone.TotalCallsCost(0.37));
myPhone.DeleteLongestCall();
Console.WriteLine("After the remove of the longest call the total price is: ${0:F2}", myPhone.TotalCallsCost(0.37));
Console.WriteLine();
myPhone.ClearHistory();
Console.WriteLine("-----------Cleared Call History-----------");
if (myPhone.CallHistory.Count == 0)
{
Console.WriteLine("There are no Recorded Calls in the History!");
}
else
{
foreach (Call call in myPhone.CallHistory)
{
Console.WriteLine(call);
}
}
}
示例4: Main
static void Main()
{
DateTime date1 = new DateTime(2013, 5, 24, 11, 11, 30);
DateTime date2 = new DateTime(2013, 5, 24, 15, 23, 2);
DateTime date3 = new DateTime(2013, 5, 31, 9, 00, 00);
DateTime date4 = new DateTime(2013, 5, 31, 18, 12, 20);
Call call1 = new Call(date1, "0888313233", 850);
Call call2 = new Call(date2, "0888909090", 95);
Call call3 = new Call(date3, "0889556677", 213);
Call call4 = new Call(date4, "0888313233", 37);
Battery battery = new Battery ("PX8", BatteryType.LiIon, 300, 8);
Display display = new Display(4, 16000000);
GSM gsm = new GSM("I900", "Samsung", 500, "Me", battery, display);
gsm.AddCalls(call1);
gsm.AddCalls(call2);
gsm.AddCalls(call3);
gsm.AddCalls(call4);
foreach (var call in gsm.CallHistory)
{
Console.WriteLine(call);
}
Console.WriteLine("Total amount to pay: {0:C}",gsm.TotalCallsPrice);
gsm.DeleteCalls(call1);
Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice);
gsm.ClearHistory();
Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice);
}
示例5: Main
static void Main(string[] args)
{
GSM gsm = new GSM("Galaxy", "Samsung");
gsm.AddCall(new Call("+359884211", 1, 0.5));
gsm.AddCall(new Call("+359884212", 2, 0.5));
gsm.AddCall(new Call("+359884213", 3, 0.5));
gsm.AddCall(new Call("+359884214", 4, 0.2));
Console.WriteLine("Call History:");
Console.WriteLine();
foreach (Call call in gsm.CallHistory)
{
Console.WriteLine(call);
}
Console.WriteLine("Total Calls Price: {0}", gsm.CalculteTotalCallsPrice());
var longestCall = gsm.CallHistory
.OrderByDescending(x => x.Duration)
.First();
gsm.DeleteCall(longestCall);
Console.WriteLine("Total Calls Price after longest call is deleted: {0}", gsm.CalculteTotalCallsPrice());
gsm.ClearHistory();
if (gsm.CallHistory.Count == 0)
{
Console.WriteLine("No calls in calls history available!");
}
}
示例6: Main
static void Main()
{
//GSM Test
GSM[] mobilePhoneArray = new GSM[3];
Display testDisplay = new Display(8, 160);
Battery testBattery = new Battery(BatteryType.LiIon, 10, 10);
GSM firstMobile = new GSM("Lumia", "Nokia", 350, "Pesho", testBattery, testDisplay);
mobilePhoneArray[0] = firstMobile;
GSM secondMobile = new GSM("One", "HTC", 700, "Toshko", testBattery, testDisplay);
mobilePhoneArray[1] = secondMobile;
GSM thirdMobile = new GSM("Galaxy S3", "Samsung", 500, "Ganio", testBattery, testDisplay);
mobilePhoneArray[2] = secondMobile;
for (int i = 0; i < mobilePhoneArray.Length; i++)
{
Console.WriteLine(mobilePhoneArray[i]);
Console.WriteLine(new string('=', 17));
Console.WriteLine();
}
Console.WriteLine(GSM.Iphone.Model);
Console.WriteLine(GSM.Iphone.Manufacturer);
Console.WriteLine(GSM.Iphone.Price);
Console.WriteLine();
//GSM Call History Test
GSM myPhone = new GSM("Lumia", "Nokia", 459, "Kiro", testBattery, testDisplay);
myPhone.AddCall(DateTime.Now, "0884647523", 456);
myPhone.AddCall(DateTime.Now, "0894547579", 320);
myPhone.AddCall(DateTime.Now, "0875578923", 15);
myPhone.AddCall(DateTime.Now, "0888987051", 45);
myPhone.AddCall(DateTime.Now, "0880600700", 32);
myPhone.AddCall(DateTime.Now, "0875657258", 69);
myPhone.DisplayCallHistory();
Console.WriteLine(myPhone.CalcPrice(0.37));
myPhone.RemoveCallByDuration(456);
myPhone.DisplayCallHistory();
Console.WriteLine(myPhone.CalcPrice(0.37));
myPhone.ClearHistory();
myPhone.DisplayCallHistory();
}
示例7: Main
static void Main()
{
// GSMTest
GSM[] test = new GSM[3];
Display testDisplay = new Display(12, 13);
Battery testBattery = new Battery(BatteryType.LiIon, 10, 10);
GSM firstPhone = new GSM("test", "test", 12, "Bai Ivan", testBattery, testDisplay);
test[0] = firstPhone;
GSM secondPhone = new GSM("SecondTest", "SecondTest", 14, "Moore Name", testBattery, testDisplay);
test[1] = secondPhone;
GSM thirdPhone = new GSM("Some test", "Texttt", 1, "Name", testBattery, testDisplay);
test[2] = thirdPhone;
for (int i = 0; i < test.Length; i++)
{
Console.WriteLine(test[i]);
}
Console.WriteLine(GSM.Iphone.Model);
Console.WriteLine(GSM.Iphone.Manufacturer);
Console.WriteLine(firstPhone.Battery.BatteryModel);
Console.WriteLine("---------------------------------");
Console.WriteLine("GSMCallHistoryTest");
Console.WriteLine("---------------------------------");
//GSMCallHistoryTest
GSM myPhone = new GSM("Nokia", "Nokia Corp", 1, "Ivan", testBattery, testDisplay);
myPhone.AddCall(DateTime.Now, "088888888", 236);
myPhone.AddCall(DateTime.Now, "077777777", 333);
myPhone.AddCall(DateTime.Now, "066666666", 123);
myPhone.AddCall(DateTime.Now, "055555555", 11);
myPhone.AddCall(DateTime.Now, "044444444", 23);
myPhone.DisplayCallHistory();
Console.WriteLine(myPhone.CalcPrice(0.37));
myPhone.RemoveCallByDuration(333);
myPhone.DisplayCallHistory();
Console.WriteLine(myPhone.CalcPrice(0.37));
myPhone.ClearHistory();
myPhone.DisplayCallHistory();
}
示例8: Main
static void Main()
{
// GSMTest
GSM[] test = new GSM[3];
Display testDisplay = new Display(5, 65000);
Battery testBattery = new Battery(BatteryType.LiIon, 15, 20);
GSM firstPhone = new GSM("StarII", "Samsung", 120, "Pesho", testBattery, testDisplay);
test[0] = firstPhone;
Display test2Display = new Display(3, 250);
Battery test2Battery = new Battery(BatteryType.NiCd, 10, 12);
GSM secondPhone = new GSM("Desire 300", "HTC", 300, "Ivan", test2Battery, test2Display);
test[1] = secondPhone;
Display test3Display = new Display(7, 255000);
Battery test3Battery = new Battery(BatteryType.NiMH, 5, 6);
GSM thirdPhone = new GSM("Lumbia 625", "Nokia", 650, "Kalina", test3Battery, test3Display);
test[2] = thirdPhone;
for (int i = 0; i < test.Length; i++)
{
Console.WriteLine(test[i]);
}
Console.WriteLine(GSM.Iphone.Model);
Console.WriteLine(GSM.Iphone.Manufacturer);
Console.WriteLine(firstPhone.Battery.BatteryModel);
Console.WriteLine(new string('-',70));
Console.WriteLine("GSM CALL Histiry Test");
Console.WriteLine(new string('-', 70));
//GSM Call History Test
GSM myPhone = new GSM("IPhone4S", "Apple", 450, "Lili", testBattery, testDisplay);
myPhone.AddCall(DateTime.Now, "0888665533", 55);
myPhone.AddCall(DateTime.Now, "0888345678", 512);
myPhone.AddCall(DateTime.Now, "0888123456", 238);
myPhone.AddCall(DateTime.Now, "0888987654", 5);
myPhone.AddCall(DateTime.Now, "0888244668", 105);
myPhone.AddCall(DateTime.Now, "0888133557", 89);
myPhone.AddCall(DateTime.Now, "0888435465", 72);
myPhone.DisplayCallHistory();
Console.WriteLine(myPhone.CalcPrice(0.37));
myPhone.RemoveCallByDuration(105);
myPhone.DisplayCallHistory();
Console.WriteLine(myPhone.CalcPrice(0.37));
myPhone.ClearHistory();
myPhone.DisplayCallHistory();
}
示例9: 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();
}
示例10: Main
static void Main()
{
GSM phone = new GSM("Moto X", "Motorola");
phone.AddCall(DateTime.Now, "0899789987", 500);
phone.AddCall(new DateTime(2013, 2, 16), "0899233987", 350);
phone.AddCall(new DateTime(2013, 2, 12), "0899123456", 58);
phone.AddCall(new DateTime(2013, 2, 13), "0899123456", 58);
phone.AddCall(new DateTime(2013, 2, 14), "0899123456", 69);
phone.AddCall(new DateTime(2013, 2, 14), "0899123456", 69);
Console.WriteLine(phone.ToString());
phone.ShowCallHistory();
phone.CalcPrice(0.37M);
phone.RemoveLongestCall();
phone.CalcPrice(0.37M);
phone.ClearHistory();
phone.ShowCallHistory();
}
示例11: Main
static void Main(string[] args)
{
//Create an instance of the GSM class.
Battery phoneBattery = new Battery("NiCd", 30.6, 5.6);
Display phoneDisplay = new Display(5.0, 16000000);
GSM phone = new GSM("Galaxy Note", "Samsung", 866, "Goran Bregovic", phoneBattery, phoneDisplay);
//Add few calls.
DateTime dateAndTime = new DateTime(2013, 3, 5, 11, 59, 59);
Call callOne = new Call(dateAndTime, "0888455455", 110);
Call callTwo = new Call(dateAndTime, "0899455455", 50);
Call callThree = new Call(dateAndTime, "0886455455", 230);
phone.AddCall(callOne);
phone.AddCall(callTwo);
phone.AddCall(callThree);
//Display the information about the calls.
//Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
Console.WriteLine(phone.CallHistoryToString);
double price = phone.CalculatePrice(0.37);
Console.WriteLine("The price for the whole history is {0}", price);
//Remove the longest call from the history and calculate the total price again.
uint maxDuritation = uint.MinValue;
Call callToRemove = new Call(dateAndTime, "0886455455", 0);
for (int i = 0; i < phone.CallHistory.Count; i++)
{
if (phone.CallHistory[i].Duritation > maxDuritation)
{
maxDuritation = phone.CallHistory[i].Duritation;
callToRemove = phone.CallHistory[i];
}
}
phone.DeleteCall(callToRemove);
price = phone.CalculatePrice(0.37);
Console.WriteLine("The new price after we removed the longest call is {0}", price);
//Finally clear the call history and print it.
Console.WriteLine();
Console.WriteLine("Clearing History...");
phone.ClearHistory();
Console.WriteLine("Call History: {0}", phone.CallHistoryToString);
}
示例12: 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();
}
示例13: 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);
}
示例14: Main
static void Main(string[] args)
{
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
GSM NokiaGSM = new GSM("Nokia", "NK", 180, "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.CalculatePriceAllCalls(NokiaGSM.CallHistory, 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.CalculatePriceAllCalls(NokiaGSM.CallHistory, 0.37m));
NokiaGSM.ClearHistory(NokiaGSM.CallHistory);
Console.Write("After clearing the history, there are {0} calls.", NokiaGSM.CallHistory.Count);
Console.WriteLine();
}
示例15: Main
static void Main()
{
//GSMTest Display the information about the GSMs in the array.
GSM[] myGSMs = new GSM[5];
GSM phone;
for (int i = 0; i < myGSMs.Length; i++)
{
phone = new GSM("model "+i,"manufact");
myGSMs[i]=phone;
Console.WriteLine(myGSMs[i].ToString());
}
//Display the information about the static property IPhone4S
GSM.iPhone4s.ToString();
//Add few calls.
phone = new GSM("jhgfhjg540", "manufact");
Random rand = new Random();
int phoneForDelete=0;
for (int i = 0; i < 5; i++)
{
phone.AddCall(DateTime.Now, rand.Next(100000, 9999999).ToString(), rand.Next(1, 250));
if (i==2)
{
phoneForDelete=rand.Next(100000, 9999999);
phone.AddCall(DateTime.Now, phoneForDelete.ToString(), rand.Next(1, 250));
i++;
}
}
//Display the information about the calls.
phone.DisplayCallHistory();
//Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
Console.WriteLine("Price: "+phone.CalcPrice(0.37));
//Remove the longest call from the history and calculate the total price again.
phone.DeleteCall(phoneForDelete.ToString());
phone.DisplayCallHistory();
//Finally clear the call history and print it
phone.ClearHistory();
phone.DisplayCallHistory();
}