static void Main() { // TASK 7 // Create Gsm objects using different constructors Gsm firstGsm = new Gsm("1320", "Nokia", 120.50, "Nakov", new Battery("Varta", 336, 12, BatteryType.NiMn), new Display(6, 32)); Gsm secondGsm = new Gsm("J132", "Sony-Ericson"); Gsm thirdGsm = new Gsm("Banan", "Plod-Zelenchuk", 50, "Mitko Berbatov", null, null); // Initialize a Gsm array Gsm[] phones = { firstGsm, secondGsm, thirdGsm }; // Display information for each Gsm in the array foreach (var phone in phones) { Console.WriteLine(phone.ToString() + Environment.NewLine); } // Display static property iPhone4S Console.WriteLine("STATIC PROPERTY:"); Console.WriteLine(Gsm.IPhone4S); Console.WriteLine("END OF TASK 7. Press any key to start task 12"); Console.ReadKey(); Console.WriteLine(); // TASK 12 Console.WriteLine("TASK 12:" + Environment.NewLine); GSMCallHistoryTest.TestCallHistory(); // TASK 12 }
static Gsm() { IPhone4S = new Gsm( MobilePhoneManufacturer.Apple, new Battery(BatteryType.LiPoly, "5.3 Wh", 200, 0, 8, 0), new Display(640, 960, 3.5, ColorDepth.Colors16M), "Apple iPhone 4S", 380, null); }
public void TestGsmConstructor5() { Gsm mobilePhone = new Gsm(MobilePhoneManufacturer.Nokia, new Battery(BatteryType.LiIon, "BL-4U", 600, 0, 17, 0), new Display(240, 400, 3.0, ColorDepth.Colors65K), "Nokia Asha 310", 90, "Dustin Hoffman"); Assert.AreEqual(17, mobilePhone.Battery.TalkTime.Hours); }
public void TestGsmConstructor6() { Gsm mobilePhone = new Gsm(MobilePhoneManufacturer.Nokia, new Battery(BatteryType.LiIon, "BL-4U", 600, 0, 17, 0), new Display(240, 400, 3.0, ColorDepth.Colors65K), "Nokia Asha 310", 90, "Dustin Hoffman"); Assert.AreEqual(240, mobilePhone.Display.Size.ResolutionWidth); }
public static void TestCallHistory() { // Create an instance of the GSM class Gsm finalTestGsm = new Gsm("Lumia", "Nokia"); // Add a few calls finalTestGsm.MakeCall("123", 30); finalTestGsm.MakeCall("0883-123-456", 124); finalTestGsm.MakeCall("0889-123-789", 400); // Display information about the calls for (int i = 0; i < finalTestGsm.CallHistory.Count; i++) { Console.WriteLine("Call {0} information:", i + 1); Console.WriteLine(finalTestGsm.CallHistory[i] + Environment.NewLine); } // Print total price of calls Console.WriteLine("Total price of calls: {0}" + Environment.NewLine, finalTestGsm.CalculatePrice(0.37)); // Remove longest call and calculate total price again int longestCallIndex = 0; int longestCallDuration = 0; for (int i = 0; i < finalTestGsm.CallHistory.Count; i++) { if (finalTestGsm.CallHistory[i].CallDuration > longestCallDuration) { longestCallDuration = finalTestGsm.CallHistory[i].CallDuration; longestCallIndex = i; } } finalTestGsm.DeleteCall(longestCallIndex); Console.WriteLine("Total price of calls after removal of longest call: {0}" + Environment.NewLine, finalTestGsm.CalculatePrice(0.37)); // Clear call history and print it finalTestGsm.ClearCallHistory(); if (finalTestGsm.CallHistory.Count == 0) { Console.WriteLine("The call history is empty."); } else { for (int i = 0; i < finalTestGsm.CallHistory.Count; i++) { Console.WriteLine("Call {0} information:", i + 1); Console.WriteLine(finalTestGsm.CallHistory[i] + Environment.NewLine); } } }
public void TestTotalCallPrice2() { // create an instance of the Gsm class Gsm mobilePhone = new Gsm( MobilePhoneManufacturer.BlackBerry, new Battery(BatteryType.LiIon, null, 432, 0, 7, 0), new Display(320, 240, 2.44, ColorDepth.Colors65K), "BlackBerry Curve 9320", 170, "Julia Roberts"); // calculate total call price (given the price per minute) decimal totalCallPrice = mobilePhone.CalculateTotalCallPrice(0.37M); Assert.AreEqual(0, totalCallPrice); }
private static void Main() { // Gsm and other class test Gsm firstPhone = new Gsm("HD2", "HTC", 300, new Person("Peshko", "Peshev"), new Battery("Rechargable", 12, 22, BatteryType.NiMH), new Display(6, 200000)); Gsm secondPhone = new Gsm("1010", "Nokia", 400, new Person("Mincho", "Minchev"), new Battery("Rechargable", 12, 32, BatteryType.NiCd), new Display(4, 400000)); Gsm thirdPhone = new Gsm("S4", "Samsung", 600, new Person("Slivko", "Slivkov"), new Battery("Rechargable", 12, 22, BatteryType.LiIon), new Display(7, 500000)); Gsm fourthPhone = new Gsm("HTC HD2", "HTC", 1.0m, new Person("Az", "Sum"), new Battery("kdjfkdf", 1, 1, BatteryType.LiIon), new Display(1, 1)); List<Gsm> phones = new List<Gsm>(); phones.Add(firstPhone); phones.Add(secondPhone); phones.Add(thirdPhone); phones.Add(fourthPhone); foreach (var phone in phones) { Console.WriteLine(phone); } Console.WriteLine(Gsm.IPhone4s); // Call History Tests firstPhone.AddCall(new Call(DateTime.Now, "123123", 123)); Console.WriteLine("Calls: " + firstPhone.CallHistory.Count); firstPhone.ClearCallHistory(); Console.WriteLine("Calls: " + firstPhone.CallHistory.Count); firstPhone.AddCall(new Call(DateTime.Now, "0888123123", 123)); firstPhone.AddCall(new Call(DateTime.Now.AddSeconds(123), "0878333111", 321)); firstPhone.AddCall(new Call(DateTime.Now.AddSeconds(321), "0878333111", 361)); firstPhone.DisplayCallHistory(); Console.WriteLine("{0:f2} BGN", firstPhone.CalcPricePerMinute(0.37m)); firstPhone.RemoveLongestCallAndCalcPpm(0.37m); // Finally clear the call history and print it. firstPhone.ClearCallHistory(); firstPhone.DisplayCallHistory(); }
public void TestDeleteLongestCallFromHistory() { // create an instance of the Gsm class Gsm mobilePhone = new Gsm( MobilePhoneManufacturer.BlackBerry, new Battery(BatteryType.LiIon, null, 432, 0, 7, 0), new Display(320, 240, 2.44, ColorDepth.Colors65K), "BlackBerry Curve 9320", 170, "Julia Roberts"); // add a few calls mobilePhone.AddCallToHistory(2012, 8, 28, 13, 5, "00359 888 967584", 129); mobilePhone.AddCallToHistory(2012, 10, 15, 9, 34, "00359 878 900581", 907); mobilePhone.AddCallToHistory(2012, 12, 9, 2, 15, "00359 882 123456", 457); mobilePhone.AddCallToHistory(2013, 1, 7, 1, 57, "00359 883 969956", 307); mobilePhone.AddCallToHistory(2013, 2, 5, 10, 27, "00359 879 967584", 456); mobilePhone.AddCallToHistory(2013, 2, 12, 15, 45, "00359 885 962387", 907); // delete the longest call from history int callsRemoved = mobilePhone.DeleteLongestCallFromHistory(); Assert.AreEqual(2, callsRemoved); }
public void TestTotalCallPrice1() { // create an instance of the Gsm class Gsm mobilePhone = new Gsm( MobilePhoneManufacturer.BlackBerry, new Battery(BatteryType.LiIon, null, 432, 0, 7, 0), new Display(320, 240, 2.44, ColorDepth.Colors65K), "BlackBerry Curve 9320", 170, "Julia Roberts"); // add a few calls mobilePhone.AddCallToHistory(2012, 8, 28, 13, 5, "00359 888 967584", 129); mobilePhone.AddCallToHistory(2012, 10, 15, 9, 34, "00359 878 900581", 907); mobilePhone.AddCallToHistory(2012, 12, 9, 2, 15, "00359 882 123456", 457); mobilePhone.AddCallToHistory(2013, 1, 7, 1, 57, "00359 883 969956", 307); mobilePhone.AddCallToHistory(2013, 2, 5, 10, 27, "00359 879 967584", 456); mobilePhone.AddCallToHistory(2013, 2, 12, 15, 45, "00359 885 962387", 812); // calculate total call price (given the price per minute) decimal totalCallPrice = mobilePhone.CalculateTotalCallPrice(0.37M); Assert.AreEqual(18.92M, Math.Round(totalCallPrice, 2)); }
public static void Test() { Gsm nexus5 = new Gsm ("Nexus 5", "Google", 400m, "Goshko", new Battery("Samsing HyperPower", 20, 11, BatteryType.LiIon), new Display(NumberOfColors.Color16M, 4.7)); nexus5.AddCall(new Call(DateTime.Now, "0882199256", 60)); nexus5.AddCall(new Call(DateTime.Now, "0882199256", 60)); nexus5.AddCall(new Call(DateTime.Now, "0882199256", 120)); Console.WriteLine(nexus5.DisplayCallsinfo()); Console.WriteLine("Final Price: {0:0.00}", nexus5.CalculateTotalPriceCalls(0.37m).ToString("C", CultureInfo.GetCultureInfo("en-US"))); nexus5.RemoveLongestCall(); Console.WriteLine("Final Price after removal: {0:0.00}", nexus5.CalculateTotalPriceCalls(0.37m).ToString("C", CultureInfo.GetCultureInfo("en-US"))); nexus5.ClearCallList(); Console.WriteLine(nexus5.DisplayCallsinfo()); }
public void TestGsmConstructor13() { Gsm mobilePhone = new Gsm( MobilePhoneManufacturer.Motorola, new Battery(), new Display(), "Motorola ATRIX HD MB886"); Assert.AreEqual(null, mobilePhone.Battery.StandByTime.Hours); }
public void TestClearHistory() { // create an instance of the Gsm class Gsm mobilePhone = new Gsm( MobilePhoneManufacturer.BlackBerry, new Battery(BatteryType.LiIon, null, 432, 0, 7, 0), new Display(320, 240, 2.44, ColorDepth.Colors65K), "BlackBerry Curve 9320", 170, "Julia Roberts"); // add a few calls mobilePhone.AddCallToHistory(2012, 8, 28, 13, 5, "00359 888 967584", 129); mobilePhone.AddCallToHistory(2012, 10, 15, 9, 34, "00359 878 900581", 907); mobilePhone.AddCallToHistory(2012, 12, 9, 2, 15, "00359 882 123456", 457); mobilePhone.AddCallToHistory(2013, 1, 7, 1, 57, "00359 883 969956", 307); mobilePhone.AddCallToHistory(2013, 2, 5, 10, 27, "00359 879 967584", 456); mobilePhone.AddCallToHistory(2013, 2, 12, 15, 45, "00359 885 962387", 812); // clear call history mobilePhone.ClearCallHistory(); Assert.AreEqual(String.Empty, mobilePhone.GetCallHistory()); }
public void TestGsmConstructor15() { Gsm mobilePhone = new Gsm( MobilePhoneManufacturer.Motorola, null, null, "Motorola ATRIX HD MB886"); Assert.AreEqual(null, mobilePhone.Display.Size.ResolutionWidth); }
public void TestGsmConstructor16_ThrowsException() { Gsm mobilePhone = new Gsm( MobilePhoneManufacturer.Unknown, null, null, "Motorola ATRIX HD MB886"); }
public void TestGsmConstructor14() { Gsm mobilePhone = new Gsm( MobilePhoneManufacturer.Motorola, null, new Display(), "Motorola ATRIX HD MB886"); Assert.AreEqual(null, mobilePhone.Battery.TalkTime.Minutes); }
public void TestGsmConstructor17_ThrowsException() { Gsm mobilePhone = new Gsm( MobilePhoneManufacturer.SonyEricsson, null, null, ""); }