本文整理汇总了C#中GSM.CalcPrice方法的典型用法代码示例。如果您正苦于以下问题:C# GSM.CalcPrice方法的具体用法?C# GSM.CalcPrice怎么用?C# GSM.CalcPrice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GSM
的用法示例。
在下文中一共展示了GSM.CalcPrice方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: 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();
}
示例4: 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();
}
示例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()
{
//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();
}
示例7: Main
static void Main()
{
GSM firstGSM = new GSM();
// USER INPUT
//Console.WriteLine("Enter phone model: ");
//firstGSM.Model = Console.ReadLine();
//Console.WriteLine("Enter manufacturer: ");
//firstGSM.Manufacturer = Console.ReadLine();
//Console.WriteLine("Enter price: ");
//firstGSM.Price = int.Parse(Console.ReadLine());
//Console.WriteLine("Enter owner: ");
//firstGSM.Owner = Console.ReadLine();
//Console.WriteLine("Enter battery model between Li-Ion,NiMH,NiCD(0-2): ");
//firstGSM.Battery.Model = (BatteryType)int.Parse(Console.ReadLine());
//Console.WriteLine("Enter hours idle: ");
//firstGSM.Battery.HoursIdle = double.Parse(Console.ReadLine());
//Console.WriteLine("Enter hours talked: ");
//firstGSM.Battery.HoursTalked = double.Parse(Console.ReadLine());
//Console.WriteLine("Enter display size: ");
//firstGSM.Display.Size = uint.Parse(Console.ReadLine());
//Console.WriteLine("Enter display colours: ");
//firstGSM.Display.Colours = uint.Parse(Console.ReadLine());
//AUTO INPUT
firstGSM.Model = "Galaxy S";
firstGSM.Manufacturer = "Samsung";
firstGSM.Price = 899;
firstGSM.Owner = "The Owner";
firstGSM.Battery.Model = BatteryType.NiCD;
firstGSM.Battery.HoursIdle = 216.5;
firstGSM.Battery.HoursTalked = 15.5;
firstGSM.Display.Size = 11;
firstGSM.Display.Colours = 65356;
firstGSM.Print();
firstGSM.Battery.Print();
firstGSM.Display.Print();
GSM newGSM = new GSM("IPhone","Apple");
newGSM.Print();
newGSM.Battery.Print();
newGSM.Display.Print();
GSM thirdGSM = new GSM("Phone", "Manufact", 106, "Over");
thirdGSM.Print();
//Create an array of few instances of the GSM class
GSM[] myGSM = new GSM[3];
myGSM[0] = new GSM("Galaxy S2", "Samsung", 750, "Nikolai");
myGSM[1] = new GSM("3110", "Nokia", 10, "Nikolai");
myGSM[2] = new GSM("N70", "Nokia", 300, "Nikolai");
//Display the information about the GSMs in the array
for (int i = 0; i < myGSM.Length; i++)
{
myGSM[i].Print();
}
Console.WriteLine();
//Display the information about the static property IPhone4S.
GSM.IPhone4S.Print();
//Assume the price per minute is fixed and is provided as a parameter.
//Assuming that the price per minute is 0.37
double pricePerMin = 0.37;
//Create an instance of the GSM class.
GSM lastGSM = new GSM("Xperia", "Nokia", 800, "Pesho");
//Add few calls.
lastGSM.AddCall("08955454521", 300);
lastGSM.AddCall("25665663663", 165);
lastGSM.AddCall("252689657954", 214);
List<Call> history = lastGSM.CallHistory;
//Display the information about the calls.
foreach (var call in history)
{
call.PrintCall();
Console.WriteLine();
}
//Calculate and print the total price of the calls in the history.
Console.WriteLine("The price for the calls is : {0}", lastGSM.CalcPrice(pricePerMin));
//Select the longest call
int maxDurationIndex = 0;
uint maxDuration = 0;
for (int i = 0; i < history.Count; i++)
{
if (history[i].Duration > maxDuration)
{
//.........这里部分代码省略.........