本文整理汇总了C#中GSM类的典型用法代码示例。如果您正苦于以下问题:C# GSM类的具体用法?C# GSM怎么用?C# GSM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GSM类属于命名空间,在下文中一共展示了GSM类的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: Test
public static void Test()
{
GSM[] phones = new GSM[]
{
new GSM("3310", "Nokia", 200m, "John",
new Battery("123-23AFF", BatteryType.LiIon, 24, 3),
new Display(4, 1)),
new GSM("k700i", "Sony-Ericsson", 50m, "Me",
new Battery("Ox-315F", BatteryType.Unknown, 48, 5),
new Display(4, 65000)),
new GSM("Lumnia", "Nokia"),
new GSM("iPhone", "Apple",
new Battery("aa-22", 100, 10),
new Display(8, 2000000)),
new GSM("M-35", "Siemens", 50m, "Radi predi 10 godini")
};
foreach (var gsm in phones)
{
Console.WriteLine("=========================");
Console.WriteLine(gsm);
}
Console.WriteLine("=========================");
Console.WriteLine(GSM.IPhone4S);
}
示例3: 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);
}
}
示例4: TestHistoryDisplay
public void TestHistoryDisplay()
{
GSM phone = new GSM("lala", "sumsAng", "batman", 10000.99);
DateTime date = new DateTime();
DateTime.TryParse("2.2.2013 14:34", out date);
phone.MakeCall(date, "0899999999", 3.44);
DateTime.TryParse("6.2.2013 19:34:11", out date);
phone.MakeCall(date, "0899999999", 3.44);
DateTime.TryParse("11.2.2013 12:32:59", out date);
phone.MakeCall(date, "0889666999", 9.44);
DateTime.TryParse("12.2.2013 15:30:00", out date);
phone.MakeCall(date, "0009666999", 9.44);
string expected = @"12-Feb-13 15:30:00
11-Feb-13 12:32:59
06-Feb-13 19:34:11
02-Feb-13 14:34:00
";
StringBuilder sb = new StringBuilder();
foreach (var item in phone.GetCallsByDate())
{
sb.AppendLine(item.ToString());
}
Assert.AreEqual(expected, sb.ToString());
}
示例5: Main
static void Main()
{
GSM gsm = new GSM("nokia", "nokiaman");
GSM gsm1 = new GSM("nokia", "nok", 9.5m);
Battery bat = new Battery("monbat", 500, 100, BatteryType.NiMH);
Display dis = new Display(null, 256);
GSM gsm2 = new GSM("erik", "erik", bat);
GSM gsm3 = new GSM("koko", "ka", dis);
Console.WriteLine(gsm.ToString());
Console.WriteLine("-----");
Console.WriteLine(gsm1.ToString());
Console.WriteLine("-----");
Console.WriteLine(gsm2.ToString());
Console.WriteLine("-----");
Console.WriteLine(gsm3.ToString());
Console.WriteLine("---------------------------");
GSM p = GSM.IPhone4S;
p.Owner = "pesho";
p.Battery = bat;
Console.WriteLine(p.ToString());
GSMCallHistoryTest.Test();
}
示例6: TestRunner
public static void TestRunner()
{
// Create a few instances of the GSM class
List<GSM> mobilePhones = new List<GSM>();
// Mobile N.1
{
mobilePhones.Add(new GSM("Asha 501", "Nokia", "GLOBUL", 599.99m, new Display(3, 1250000)));
}
// Mobile N.2
{
GSM mobile = new GSM("Xperia ray", "Sony Ericsson");
mobile.Owner = "Vivacom";
mobile.Price = 250;
mobile.Battery = new Battery(Battery.Type.NiMH);
mobile.Battery.HoursTalk = 200;
mobilePhones.Add(mobile);
}
// Display information about phones in array
foreach (var phone in mobilePhones)
Console.Write(phone);
// Mobile N.3
// Display information about IPhone 4S
Console.Write(GSM.Iphone4S);
}
示例7: 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);
}
示例8: Main
static void Main()
{
GSM[] mobilePhones = new GSM[3];
GSM nokia = new GSM("3310", "Nokia");
nokia.AddHistory(DateTime.Now, 0998080907, 1.08);
nokia.AddHistory(DateTime.Now, 0998080907, 2132331.08);
nokia.DeleteHistory(1);
Battery sonyBattery5511 = new Battery("77ds7", 220, 10, BatteryType.NiMH);
Display sonyDisplay5511 = new Display(23, 128);
GSM sony = new GSM("5511", "Sony", 100.77m, "Pesho", sonyBattery5511, sonyDisplay5511);
GSM samsung = new GSM("4433", "samsung", 50.22m, "Gosho");
mobilePhones[0] = nokia;
mobilePhones[1] = sony;
mobilePhones[2] = samsung;
//Console.WriteLine(nokia.CalcPriceHistory(2.2m));
for (int i = 0; i < mobilePhones.Length; i++)
{
Console.WriteLine(mobilePhones[i]);
}
}
示例9: 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);
}
}
示例10: Main
static void Main(string[] args)
{
GSM[] gsmArray = new GSM[3];
Battery myBattery = new Battery("Nokia", 50,50, BatteryType.LiIon);
Display myDisplay = new Display(10, 1000000);
GSM firstGsm = new GSM("N8", "Nokia", 500, "Me", myBattery, myDisplay);
gsmArray[0] = firstGsm;
myBattery = new Battery("Samsung", 60, 60, BatteryType.NiCd);
myDisplay = new Display(12, 1200000);
GSM secondGsm = new GSM("Galaxy", "Samsung", 700, "Me", myBattery, myDisplay);
gsmArray[1] = secondGsm;
myBattery = new Battery("HTC", 40, 40, BatteryType.NiMH);
myDisplay = new Display(8, 800000);
GSM thirdGsm = new GSM("K8", "HTC", 450, "Me", myBattery, myDisplay);
gsmArray[2] = thirdGsm;
foreach (var item in gsmArray)
{
Console.WriteLine(item);
Console.WriteLine();
}
Console.WriteLine(GSM.IPhone4S);
GSMCallHistoryTest.Test();
}
示例11: Main
static void Main()
{
GSM[] gsmArr = new GSM[3];
string[] gsmModelArr = { "N90","5800","N70"};
string[] gsmManufacturerArr = { "Nokia","HTC","Samsung"};
decimal[] gsmPriceArr = { 1000m, 200.34m, 2000.3434m};
string[] gsmOwnerArr = { "IBot","IDummy","IWorm"};
for (int i = 0; i < gsmArr.Length; i++)
{
gsmArr[i] = new GSM(gsmModelArr[i], gsmManufacturerArr[i], gsmPriceArr[i], gsmOwnerArr[i]);
Console.WriteLine("Override ToString(): ");
Console.WriteLine(gsmArr[i].ToString());
Console.WriteLine(gsmModelArr[i]);
Console.WriteLine(gsmManufacturerArr[i]);
Console.WriteLine(gsmPriceArr[i]);
Console.WriteLine(gsmOwnerArr[i]);
}
GSM iphone = new GSM(null,null);
iphone.iPhone4s.PhoneManufacturer = "Apple Corp.";
iphone.iPhone4s.PhoneModel = "iPhone 4 S";
Console.WriteLine(iphone.iPhone4s.PhoneManufacturer);
Console.WriteLine(iphone.iPhone4s.PhoneModel);
}
示例12: 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();
}
示例13: 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();
}
示例14: 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();
}
示例15: Main
static void Main()
{
Console.WriteLine("GSM instances test");
Console.WriteLine(new string('-', 30));
//creates array with GSM instances
var gsms = new GSM[]
{
new GSM("Galaxy S3","Samsung"),
new GSM("G2 Mini", "LG", 190, new Battery("2440 mAh", 700, 12, Battery.Type.LiIon), new Display(540, 960, 16000000), "Martin"),
new GSM("Nexus 6", "Motorola", new Display(1440, 2560)),
new GSM("One M9", "HTC", 500, new Battery("Non-removable 2840 mAh", 391, 25), new Display(1080, 1920, 160000000))
};
//displays the information about the GSMs in the array
foreach (var gsm in gsms)
{
Console.WriteLine(gsm.ToString());
}
//displays the information about the static property IPhone4S
Console.WriteLine("Information about iPhone 4S: ");
Console.WriteLine(new string('-', 30));
Console.WriteLine(GSM.IPhone4S);
//tests calls
GSMCallHistoryTest.CallHistoryTest();
}