public static void TestCallHistory() { GSM myGSM = new GSM("Xperia S", "Sony", 700, "Slim Shady", new Battery(BatteryType.LiIon, "1750", 48, 24), new Display(4.3, 16000000)); var calls = new List<Call>(); calls.Add(new Call(DateTime.Now.AddDays(-2), "+359892412424", 99)); calls.Add(new Call(DateTime.Now.AddDays(-3).AddHours(3.5), "+359884631253", 123)); calls.Add(new Call(DateTime.Now.AddDays(-4), "+359874123173", 44)); foreach (var call in calls) { myGSM.AddCallToHistory(call); } Console.WriteLine(); myGSM.PrintCallHistory(); Console.WriteLine(); Console.WriteLine("Total price is: {0:C}", myGSM.GetTotalPriceOfCalls(0.37M)); myGSM.RemoveLongestCallFromHistory(); Console.WriteLine(); Console.WriteLine("Total price without the longest call is: {0:C}", myGSM.GetTotalPriceOfCalls(0.37M)); myGSM.ClearCallHistory(); Console.WriteLine(); myGSM.PrintCallHistory(); }
public static void TestCallHistory() { GSM myGSM = new GSM("Xperia S", "Sony", 700, "Slim Shady", new Battery(BatteryType.LiIon, "1750", 48, 24), new Display(4.3, 16000000)); var calls = new List <Call>(); calls.Add(new Call(DateTime.Now.AddDays(-2), "+359892412424", 99)); calls.Add(new Call(DateTime.Now.AddDays(-3).AddHours(3.5), "+359884631253", 123)); calls.Add(new Call(DateTime.Now.AddDays(-4), "+359874123173", 44)); foreach (var call in calls) { myGSM.AddCallToHistory(call); } Console.WriteLine(); myGSM.PrintCallHistory(); Console.WriteLine(); Console.WriteLine("Total price is: {0:C}", myGSM.GetTotalPriceOfCalls(0.37M)); myGSM.RemoveLongestCallFromHistory(); Console.WriteLine(); Console.WriteLine("Total price without the longest call is: {0:C}", myGSM.GetTotalPriceOfCalls(0.37M)); myGSM.ClearCallHistory(); Console.WriteLine(); myGSM.PrintCallHistory(); }
public static void Test() { const decimal pricePerMinute = 0.37m; GSM myGsm = new GSM("Sony", "Experia e4"); myGsm.AddCallToHistory( new Call( new DateTime(2015, 2, 16, 21, 22, 3), "+3592 1111111111", new TimeSpan(0, 12, 45))); myGsm.AddCallToHistory( new Call( new DateTime(2015, 2, 17, 20, 22, 3), "+3592 2222222222", new TimeSpan(0, 10, 32))); myGsm.AddCallToHistory( new Call( new DateTime(2015, 2, 19, 17, 29, 35), "+3592 1111111111", new TimeSpan(0, 7, 3))); myGsm.AddCallToHistory( new Call( new DateTime(2015, 3, 1, 0, 48, 53), "+3592 3333333333", new TimeSpan(0, 17, 38))); Console.WriteLine(myGsm.ToString()); PrintCallHistory(myGsm); Console.WriteLine(); decimal priceOfCallHistory = myGsm.PriceOfCallHistory(pricePerMinute); Console.WriteLine("total price: {0:F4}", priceOfCallHistory); Console.WriteLine(); Call callToDelete = new Call( new DateTime(), "+3592 1111111111", new TimeSpan()); Console.WriteLine("deleting last call by number: {0}", callToDelete.DialedNumber); myGsm.DeleteCallByNumber(callToDelete); PrintCallHistory(myGsm); Console.WriteLine(); Console.WriteLine("deleting longest call"); myGsm.DeleteLongesCall(); PrintCallHistory(myGsm); priceOfCallHistory = myGsm.PriceOfCallHistory(pricePerMinute); Console.WriteLine("total price: {0:F4}", priceOfCallHistory); Console.WriteLine(); Console.WriteLine("clearing all history"); myGsm.ClearCallHistory(); PrintCallHistory(myGsm); Console.WriteLine("history cleared"); }
static void Main() { Battery firstBattery = new Battery("A2000", 500, 200, BatteryType.LiIon); Battery secondBattery = new Battery("B3000", 600, 300, BatteryType.NiCd); Battery thirdBattery = new Battery("C1000", 400, 100, BatteryType.NiMH); Display firstDisplay = new Display(5, 16000000); Display secondDisplay = new Display(4, 16000000); Display thirdDisplay = new Display(4.5, 16000000); //// GSM with all parameters GSM[] phones = new GSM[] { GSM.IPhone4S, new GSM("Idol 2", "Alcatel", 200, "P.Petrov", firstBattery, firstDisplay), new GSM("Galaxy Core 2", "Samsung", 250, "I.Ivanova", secondBattery, thirdDisplay), new GSM("P8 lite", "Huawei", 220, "P.Angelov", firstBattery, firstDisplay), new GSM("Lumia 800", "Nokia", 300, "A.Tokev", thirdBattery, secondDisplay) }; foreach (var phone in phones) { Console.WriteLine(phone); Console.WriteLine(); } //GSM with some missing parameters GSM[] secondPhonesArr = new GSM[] { new GSM("Idol 2", "Alcatel", 200), new GSM("Galaxy Core 2", "Samsung", null, "I.Ivanova"), new GSM("P8 lite", "Huawei", 220, "P.Angelov", firstBattery, firstDisplay), new GSM("Lumia 800", "Nokia", 300, "A.Tokev", thirdBattery, secondDisplay) }; foreach (var phone in secondPhonesArr) { Console.WriteLine(phone); Console.WriteLine(); } // Call history Tests GSM somePhone = new GSM("3310", "Nokia"); somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888123456", 45)); somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888111111", 15)); somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888222222", 55)); somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888333333", 65)); somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888444444", 110)); somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888555555", 20)); somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888666666", 40)); Console.WriteLine(somePhone.ShowCallHistory()); Console.WriteLine(somePhone.CallsPrice(0.37)); Console.WriteLine(); somePhone.RemoveCall(5); Console.WriteLine(somePhone.ShowCallHistory()); Console.WriteLine(somePhone.CallsPrice(0.37)); Console.WriteLine(); somePhone.ClearCallHistory(); Console.WriteLine(somePhone.ShowCallHistory()); }