本文整理汇总了C#中GSM.AddCalls方法的典型用法代码示例。如果您正苦于以下问题:C# GSM.AddCalls方法的具体用法?C# GSM.AddCalls怎么用?C# GSM.AddCalls使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GSM
的用法示例。
在下文中一共展示了GSM.AddCalls方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//test the call history functionality
static void Main()
{
//Create a new mobile phone
GSM mobile = new GSM("Xperia", "Sony", 670.99, "Kitty");
//Get information about created mobile phone
mobile.ToString();
//Get information about static field iPhone
GSM.IPhone4S.ToString();
//Add calls and print
mobile.AddCalls(DateTime.Now, "+359 885 440 340", 1);
mobile.AddCalls(DateTime.Now, "+359 886 789 451", 94);
mobile.PrintCalls();
//Delete call and print
mobile.DeleteCalls(2);
mobile.PrintCalls();
//Calculate total price
mobile.CalculateFinalPrice(0.35);
//Clear calls and print
mobile.ClearCalls();
}
示例2: 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);
}
示例3: Main
static void Main()
{
try
{
//adding battery type i the battery constructor
Battery batteryOne = new Battery("SameModel", 10, 20, BatteryType.LiIon);
Console.WriteLine("-------------------------EX3---------------------------");
Console.WriteLine(batteryOne.Type);
// creating phone
Display displayOne = new Display(55f);
GSM gsm = new GSM("55k33", "Nokia", 666, "Nqkoi", batteryOne, displayOne);
// test for override method ToString()
Console.WriteLine("-------------------------EX4---------------------------");
Console.WriteLine(gsm.ToString());
Console.WriteLine("-------------------------EX.7--------------------------");
//creating object test
GSMTests test = new GSMTests();
test.Tests();//call its method It is void method so it will directly write the data
//ex.9
Console.WriteLine("------------------------EX9---------------------------");
string dateTime ="22.12.2013 01.05.35";
DateTime day = DateTime.ParseExact(dateTime, "dd.MM.yyyy HH.mm.ss", CultureInfo.InvariantCulture);//date
string dateTime2 = "20.12.2013 01.05.35";
DateTime day2 = DateTime.ParseExact(dateTime2, "dd.MM.yyyy HH.mm.ss", CultureInfo.InvariantCulture);//date
Call firstCall = new Call(day,"0555555555",78);
Call secondCall = new Call(day2, "0555555555", 105);
Console.WriteLine(firstCall.DateAndTime);
gsm.AddCalls(firstCall);
gsm.AddCalls(secondCall);
Console.WriteLine();
Console.WriteLine(gsm.CallHistory[0].DateAndTime);
Console.WriteLine(gsm.CallHistory[1].DateAndTime);
Console.WriteLine("------------------------EX10--------------------------");
gsm.DeleteCall(secondCall);
for (int i = 0; i < gsm.CallHistory.Count; i++)
{
Console.WriteLine(gsm.CallHistory[i].DateAndTime);
}
gsm.ClearCallHistory();
Console.WriteLine("There is {0} call in the call history",gsm.CallHistory.Count);
Console.WriteLine("--------------------------EX12------------------------");
GSMCallHistoryTest testHistory = new GSMCallHistoryTest();
testHistory.GSMCallHistoryTests();
}
catch (ArgumentException exep)
{
Console.WriteLine("There is incorrect data!");
Console.WriteLine(exep.ToString());
}
}
示例4: Main
static void Main()
{
GSM testPhone = new GSM("L6", "Motorola");
testPhone.AddCalls(DateTime.Now, "0879454532", 62);
testPhone.AddCalls(DateTime.Now, "8787878789", 500);
testPhone.AddCalls(DateTime.Now, "4545454545", 420);
testPhone.AddCalls(DateTime.Now, "1111111111", 100);
testPhone.DisplayCallInformation();
double finalPrice = testPhone.CalculatePrice(0.37);
Console.WriteLine("This is the price for all the calls");
Console.WriteLine(finalPrice);
testPhone.DeleteCalls(500);
double priceAfterRemoval = testPhone.CalculatePrice(0.37);
Console.WriteLine("This is the price without the longest call:");
Console.WriteLine(priceAfterRemoval);
testPhone.ClearingHistory();
testPhone.DisplayCallInformation();
}
示例5: 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
}
示例6: Main
public static void Main()
{
//Console.Write("Enter number of phones: ");
//int number = int.Parse(Console.ReadLine());
//GSM[] phones = new GSM[number];
//for (int i = 0; i < number; i++)
//{
// Console.Write("Enter phone model: ");
// string model = Console.ReadLine();
// Console.Write("Enter phone manifacutrer: ");
// string manifacture = Console.ReadLine();
// Console.Write("Enter phone owner: ");
// string owner = Console.ReadLine();
// Console.Write("Enter phone price: ");
// string price = Console.ReadLine();
// Console.Write("Enter phone batter model: ");
// string batteryModel = Console.ReadLine();
// Console.Write("Enter phone battery idle hours: ");
// string idleHours = Console.ReadLine();
// Console.Write("Enter phone battery talk hours: ");
// string talkHours = Console.ReadLine();
// Console.Write("Enter phone display size: ");
// string displaySize = Console.ReadLine();
// Console.Write("Enter phone number of colors: ");
// string displayColors = Console.ReadLine();
// phones[i] = new GSM(model, manifacture, owner, double.Parse(price), batteryModel, int.Parse(idleHours), int.Parse(talkHours), double.Parse(displaySize), int.Parse(displayColors));
//}
//foreach (var item in phones)
//{
// Console.WriteLine();
// item.GetInfo();
//Console.WriteLine(item.ToString());
// Console.WriteLine();
//}
//---------------------------------------------------------------------------------------------------//
//CallHistoryTest
GSM mobile = new GSM("3310", "Nokia", "Some swedish guy", 100m, "ARhd34", 310, 140, 4.3f, 16000000, BatteryType.LiIon);
Console.WriteLine(mobile.ToString());
//mobile.GetInfo();
mobile.AddCalls("12:50", 0894216738, 50, 21, 12, 2013);
mobile.AddCalls("16:23", 0894216738, 120, 21, 12, 2013);
mobile.AddCalls("18:32", 0894216738, 23, 24, 12, 2013);
mobile.AddCalls("12:17", 0894216738, 180, 29, 12, 2013);
//Get info for the calls
Console.WriteLine();
foreach (var item in mobile.callHistory)
{
Console.WriteLine(item.date + " " + item.dialedNumber + " " + item.duration + " " + item.Time);
}
//Print total price
Console.WriteLine();
Console.WriteLine("Total price: {0}", mobile.CalculateTotalBill(0.37m));
//Delete longest call and print price again
mobile.callHistory.Remove(mobile.callHistory[3]);
Console.WriteLine();
Console.WriteLine("Total price: {0}", mobile.CalculateTotalBill(0.37m));
//Clear call history and print again
mobile.callHistory.Clear();
Console.WriteLine();
foreach (var item in mobile.callHistory)
{
Console.WriteLine(item.date + " " + item.dialedNumber + " " + item.duration + " " + item.Time);
}
}