本文整理汇总了C#中GSM.AddCall方法的典型用法代码示例。如果您正苦于以下问题:C# GSM.AddCall方法的具体用法?C# GSM.AddCall怎么用?C# GSM.AddCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GSM
的用法示例。
在下文中一共展示了GSM.AddCall方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTestCalls
public GSM AddTestCalls(GSM phone)
{
phone.AddCall(DateTime.Now, 3, "087612312");
phone.AddCall(DateTime.Now, 2, "089810345");
phone.AddCall(DateTime.Now, 5, "088832323");
return phone;
}
示例2: Main
static void Main()
{
GSM gsmTest = new GSM("Nokia", "E7");
gsmTest.Owner = "Me";
gsmTest.Price = 680;
gsmTest.battery.HoursIdle = 90f;
gsmTest.battery.Model = "BL-4";
gsmTest.battery.Type = BatteryType.NiCd;
gsmTest.battery.HoursTalk = 8.33f;
gsmTest.display.ColoursCount = 16000000;
gsmTest.display.Size = 4;
gsmTest.call.DialedNumber = "654135416516";
gsmTest.call.DurationInSeconds = 123;
gsmTest.AddCall(new Call("number+3590000", 120));
gsmTest.AddCall(new Call("number+3590001", 25));
gsmTest.AddCall(new Call("number+3590002", 0));
// gsmTest.PrintSpecs();
Console.WriteLine(gsmTest.ToString());
//
Console.WriteLine(gsmTest.call.DurationInSeconds);
// gsmTest.DeleteCall(1);
// gsmTest.ClearCall();
for (int i = 0; i < gsmTest.CallHistory.Count; i++)
{
Console.WriteLine(gsmTest.CallHistory[i].DurationInSeconds);
}
Console.WriteLine("Total price of the call on phone {0} {1} is : {2}", gsmTest.Manufacturer, gsmTest.Model, gsmTest.GetTotalPriceOfCalls(0.18, gsmTest));
Console.WriteLine(GSM.Iphone4S.battery.Model);
// Console.WriteLine(gsmTest.call.DurationInSeconds);
}
示例3: PhoneCalls
public void PhoneCalls()
{
GSM myPhone = new GSM("Galaxy Note II", "Samsung");
myPhone.AddCall(new DateTime(2013, 02, 1), new DateTime(), "0891111111", 1);
myPhone.AddCall(new DateTime(2013, 02, 2), new DateTime(), "0892222222", 2);
myPhone.AddCall(new DateTime(2013, 02, 3), new DateTime(), "0893333333", 3);
// Display Call History
foreach (var call in myPhone.CallHistory)
{
Console.WriteLine(call);
Console.WriteLine();
}
// Dispay the bill
Console.WriteLine("Bill: {0}lv.", myPhone.CalcBill(0.37m));
// Remove the longest call from the history and calculate the total price again.
myPhone.CallHistory.Remove(myPhone.CallHistory[2]);
Console.WriteLine("Bill without longest call: {0}lv.", myPhone.CalcBill(0.37m));
//Clear CallHistory
Console.WriteLine("Cleaned History");
myPhone.ClearAllHistory();
}
示例4: Main
static void Main()
{
GSM gsm = new GSM("Galaxy S3", "Samsung");
gsm.AddCall(846022, 150);
gsm.AddCall(35956, 132);
Console.WriteLine(gsm.CallsPrice(0.37m));
}
示例5: Main
static void Main(string[] args)
{
try
{
//Create battery and display for the GSM
Battery battery = new Battery("BL-5C",360,7,Battery.BatteryType.LithiumLon);
Display display = new Display(3,65536);
//Create GSM
GSM gsm = new GSM("1208", "nokia", 50, "Georgi", battery, display);
//Console.WriteLine(gsm.ToString()); //Print GSM data
//Mace some calls and print the history
gsm.AddCall(new Call(new DateTime(2013, 02, 22, 19, 01, 22), "00359888888888", 200));
gsm.AddCall(new Call(new DateTime(2013,02,22,20,02,33),"0887888888",302));
gsm.AddCall(new Call(new DateTime(2013, 02, 22, 20, 30, 19), "0889-88-88-88", 178));
gsm.PrintCallHistiry();
//Calculate the price of all calls
decimal price = 0.37m;
gsm.CalculateTotalCallsPrice(price);
//Remove the longest call and calculate the price again
gsm.DeleteCall(1); //The calls in the list start from 0, so the second call(longest) is 1
gsm.CalculateTotalCallsPrice(price);
//Clear the history and print it
gsm.ClearCallHistory();
gsm.PrintCallHistiry();
}
catch (Exception ex)
{
Console.WriteLine("Error!"+ex.Message);
}
}
示例6: Main
static void Main()
{
GSM NokiaN92 = new GSM("Nokia", "N82", 190, "Pesho Gosho", new Battery(Battery.Type.NiCD, 150, 13.5), new Display(2.5, 2000000000));
Console.WriteLine("Add some calls...");
NokiaN92.AddCall("0892023111", 250, 2013, 2, 25, 21, 9, 3);
NokiaN92.AddCall("0892023111", 50, 2013, 2, 22, 12, 2, 30);
NokiaN92.AddCall("0892023111", 110, 2013, 1, 7, 18, 3, 12);
Console.WriteLine("Print the calls:");
foreach (var item in NokiaN92.CallHistory)
{
Console.WriteLine(item);
}
Console.WriteLine("Calculate price of calls if the price per minute is 0.37: {0}", NokiaN92.TotalCallsPrice((decimal)0.37));
Console.WriteLine("Deleting longest call duration with the method .DeleteCall(Call)");
NokiaN92.DeleteCall(NokiaN92.CallHistory[0]);
Console.WriteLine("Calculate price of calls if the price per minute is 0.37: {0}", NokiaN92.TotalCallsPrice((decimal)0.37));
Console.WriteLine("Clear the CallHistory and print it:");
NokiaN92.ClearCallHistory();
foreach (var item in NokiaN92.CallHistory)
{
Console.WriteLine(item);
}
}
示例7: Main
static void Main(string[] args)
{
// GSM 1
GSM nokia = new GSM("Nokia", "Nokia", 15, "Nokia");
// Add Calls
Call c1 = new Call("11/14/2001","14:27:36","+123456",900);
Call c2 = new Call("11/19/2001","14:56:36","+359883442324",800);
Call c3 = new Call("11/19/2001","12:27:36","+359883442324",800);
nokia.AddCall(c1);
nokia.AddCall(c2);
nokia.AddCall(c3);
// Display Calls Info
nokia.PrintCallHistory();
// Display Total Price of All Calls
Console.WriteLine("Total Price of All Calls:{0:C2}", nokia.CallsTotalPrice(0.37m));
// Remove Call
nokia.RemoveCall(c1);
Console.WriteLine("Total Price of All Calls:{0:C2}", nokia.CallsTotalPrice(0.37m));
// Clear Call History
nokia.RemoveAllCalls();
nokia.PrintCallHistory();
}
示例8: 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);
}
}
示例9: Test
public static void Test()
{
// create new GSM instance
var huawei = new GSM(
"Ascend G600",
"Huawei",
"Mtel",
new Display(4.5, Display.ColorDepth._32Bit),
new Battery("Toshiba-tbsae", 380, 6, Battery.Type.LiPol), 600);
// add some calls to list of calls
huawei.AddCall("0888124122", 210);
huawei.AddCall("0888124122", 40);
huawei.AddCall("0888124122", 80);
huawei.AddCall("0919125121", 600);
huawei.AddCall("0919125121", 10);
huawei.ShowCalls(); // Print the call list
// Calculate the price of the each call
Console.WriteLine("The price of all calls is {0} ", huawei.CalculatePriceOfCalls(0.32m));
huawei.RemoveLongestCall();
huawei.ClearCallHistory();
huawei.ShowCalls();
}
示例10: 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();
}
示例11: 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);
}
}
}
示例12: Main
static void Main()
{
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
GSM gsm = new GSM("htc one", "HTC");
gsm.AddCall(new Call(DateTime.Now, "0897213421", 430));
gsm.AddCall(new Call(DateTime.Now, "0882345233", 630));
gsm.AddCall(new Call(DateTime.Now, "0882332432", 930));
foreach (var call in gsm.CallHistory)
{
Console.WriteLine("Date: {0}",call.Date);
Console.WriteLine("Time: {0}",call.Time);
Console.WriteLine("Number: {0}",call.DialledPhoneNumber);
Console.WriteLine("Duration: {0}",call.Duration);
Console.WriteLine("----------------------------");
}
decimal totalPriceCalls = gsm.CalcCallsTotalPrice(0.37m);
Console.WriteLine(totalPriceCalls);
int longestDuration = gsm.CallHistory.Max(c => c.Duration);
Call longestCall = gsm.CallHistory.FirstOrDefault(c => c.Duration == longestDuration);
gsm.CallHistory.Remove(longestCall);
totalPriceCalls = gsm.CalcCallsTotalPrice(0.37m);
Console.WriteLine(totalPriceCalls);
gsm.ClearCallHistory();
}
示例13: Main
static void Main()
{
GSM nokia = new GSM("N73", "Nokia", "Pesho", 360,
new Battery("BP-6M", 370, 6, BatteryType.LiIon), new Display(2.4, 243000));
GSM samsung = new GSM("GalaxyS III", "Samsung", "Gosho", 819,
new Battery("HR32", 790, 50, BatteryType.LiIon), new Display(4.8, 16000000));
GSM sonyEricsson = new GSM("Xperia Z", "Sony Ericsson", "Kiro", 864,
new Battery("PM63", 550, 40, BatteryType.LiIon), new Display(5, 16000000));
GSM vertu = new GSM("Ascent", "Vertu", "Dimcho", 10400,
new Battery("RP-M4", 150, 4, BatteryType.LiIon), new Display(0.87, 6));
GSM[] mobilePhones = { nokia, samsung, sonyEricsson, vertu, GSM.IPhone4S };
foreach (var phone in mobilePhones)
{
Console.WriteLine(phone);
Console.WriteLine("------------------------------");
}
Call callOne = new Call("0885131618", 125);
Call callTwo = new Call("0886933601", 563);
Call callThree = new Call("0886948266", 256);
vertu.AddCall(callOne);
vertu.AddCall(callTwo);
vertu.AddCall(callThree);
Console.WriteLine("Total price of all calls: {0}", vertu.CalcPriceOfCalls(0.37));
double maxDuration = 0;
string number = "";
foreach (var call in vertu.CallHistory)
{
if (maxDuration < call.Duration)
{
maxDuration = call.Duration;
number = call.DialedPhoneNumber;
}
}
Call longestCall = new Call(number, maxDuration);
Console.WriteLine("The longest call lasted {0} seconds and it is made with number {1}.", maxDuration, number);
vertu.DeleteCall(longestCall);
Console.WriteLine("Now the longest call is removed from the call history.");
Console.WriteLine("New total price of all calls: {0}", vertu.CalcPriceOfCalls(0.37));
vertu.ClearCallHistory();
Console.WriteLine("Call history is now cleared!!!");
}
示例14: Main
static void Main()
{
GSM nokia = new GSM("N7", "Nokia");
nokia.AddCall(360);
nokia.AddCall(500);
nokia.AddCall(1500);
nokia.DisplayCalls();
Console.WriteLine("The total price of the calls with 0.37st/min is {0}", nokia.CallPrice(0.37));
nokia.DeleteCall(1500);
nokia.DisplayCalls();
Console.WriteLine("The total price of the calls without the longest call is {0}", nokia.CallPrice(0.37));
}
示例15: 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();
}