static void GSMCallHistoryTest() { GSM myGSM = new GSM("Samsung", "Galaxy S2", 500, "Jimmy Hendrix", new Battery("HJ/T43456-2012", 190, 12, BatteryType.LiIon), new Display(4.7, 16)); myGSM.AddCall("22.12.2014", "11:55:32", "0888123456", 132); myGSM.AddCall("23.12.2014", "12:56:33", "0888654321", 160); myGSM.AddCall("24.12.2014", "13:57:34", "0888456123", 258); myGSM.AddCall("25.12.2014", "14:58:35", "0888654123", 400); myGSM.AddCall("26.12.2014", "15:59:36", "0888321654", 17); Console.WriteLine(myGSM.ShowCallHistory()); Console.WriteLine("Total call price: {0:F2}", myGSM.CallPrice(0.37M)); int longestCall = myGSM.CallHistory[0].Duration; int longestCallIndex = 0; for (int i = 0; i < myGSM.CallHistory.Count; i++) { int temp = myGSM.CallHistory[i].Duration; if (longestCall < temp) { longestCall = temp; longestCallIndex = i; } } myGSM.RemoveCall(myGSM.CallHistory[longestCallIndex]); // Console.WriteLine("longest call is {0}s and it costs {1:F2}", longestCall, longestCall * 0.37 / 60); Console.WriteLine("Total call price after deleting the longest call: {0:F2}", myGSM.CallPrice(0.37M)); myGSM.ClearCallHistory(); Console.WriteLine(myGSM.ShowCallHistory()); }
public static void Test() { GSM gsmNote = new GSM("Note 7", "Samsung", 1000M, "Viktor", new Battery("Samsung", 100, 40, BatteryType.LiIon), new Display(1024, 1024)); Call firstCall = new Call(); firstCall.DateTime = new DateTime(2017, 7, 18); firstCall.DialedPhoneNumber = "08888888"; firstCall.DurationInSeconds = 60; Call secondCall = new Call(); secondCall.DateTime = new DateTime(2016, 7, 18); secondCall.DialedPhoneNumber = "088888884"; secondCall.DurationInSeconds = 65; gsmNote.AddCall(firstCall); gsmNote.AddCall(secondCall); foreach (Call call in gsmNote.CallHistory) { Console.WriteLine(call); } }
//basic constructor static GSM() { iPhone4S = new GSM("iPhone4s", "Apple"); iPhone4S.price = 100000.00; iPhone4S.owner = "Not Me"; iPhone4S.battery = new Battery(BatteryType.LiPol, "refferenceModel", 1.1, 0.1); iPhone4S.display = new Display(3, 2); }
public GSMTest(int howManyDevices) { this.deviceListCount = howManyDevices; this.listOfDevices = new GSM[howManyDevices]; for (int i = 0; i < howManyDevices; i++) { listOfDevices[i] = new GSM($"[unnamedDevice{i}]", $"[unnamedModel{i}]"); } }
static void Main(string[] args) { //ako okomplektovame obekt polzvame konstruktora GSM gsm = new GSM("Note 7", " Samsung") { Price = 1000M, Owner = "Lucho", Battery = new Battery("Samsung", 100, 40, BatteryType.LiIon), Display = new Display(1024, 1024), }; Console.WriteLine(gsm); //Console.WriteLine(gsm.IPhone4s); //the below code is for abstraction and interfaces List <Calls> firstCallHistory = new List <Calls>() { new Calls() { DurationInSeconds = 15 }, new Calls() { DurationInSeconds = 25 }, new Calls() { DurationInSeconds = 35 }, }; HashSet <Calls> thirdCallHistory = new HashSet <Calls>() //lookup HashSet! { new Calls() { DurationInSeconds = 11 }, new Calls() { DurationInSeconds = 23 }, new Calls() { DurationInSeconds = 30 }, }; decimal firstPrice = GSM.CalculateCallsPrice(firstCallHistory); // // decimal second //decimal third Console.WriteLine(firstPrice); }
public static void Test() //this is incomplete { GSM gsmNote = new GSM("Note 7", "Samsung", 800, "Gosho", new Battery("Samsung", 400, 10, BatteryType.LiIon), new Display(800, 50)); GSM[] gsms = new GSM[] { GSM.IPhone4s, gsmNote }; }
public static void Test() { //tuka si igraeme s instrukciite //this is incomplete GSM iPhone5S = new GSM("IPhone5S", "Apple", 800, "Pesho", new Battery("AppleBattery", 400, 10, BatteryType.LiIon), new Display(800, 50)); Calls firstCall = new Calls(); firstCall.DateTime = new DateTime(); firstCall.DialedPhoneNumber = "21313133"; firstCall.DurationInSeconds = 60; }
public static void GSMCallHistoryTestMethod() { // Create an instance GSM gsm = new GSM(); // Add calls gsm.AddCallInHistory(new Call(DateTime.Now, "123", 35)); gsm.AddCallInHistory(new Call(DateTime.Now.AddHours(1), "456", 49)); gsm.AddCallInHistory(new Call(DateTime.Now.AddMinutes(30), "789", 63)); // Print call history for (int i = 0; i < gsm.CallHistory.Count; i++) { Console.WriteLine(gsm.CallHistory[i]); Console.WriteLine("\n----------------------------"); } // Calculate total price of calls with pricePerMinute = 0.37 Console.WriteLine(gsm.CalculateTotalPriceOfCalls(0.37)); // Remove the call with longest duration and calculate the total price again // Find the call int indexOfMaxCall = 0; int maxDuration = -1; for (int i = 0; i < gsm.CallHistory.Count; i++) { if (gsm.CallHistory[i].Duration > maxDuration) { maxDuration = gsm.CallHistory[i].Duration; indexOfMaxCall = i; } } // Remove the call and calculate the total price again gsm.DeleteCallFromHistory(gsm.CallHistory[indexOfMaxCall]); Console.WriteLine(gsm.CalculateTotalPriceOfCalls(0.37)); // Clear the call history gsm.ClearCallHistory(); for (int i = 0; i < gsm.CallHistory.Count; i++) { Console.WriteLine(gsm.CallHistory[i]); Console.WriteLine("\n----------------------------"); } }
public void GSMArrayTest() { GSM[] tests = new GSM[4]; tests[0] = new GSM("3310", "Nokia"); tests[1] = new GSM("Desire", "HTC", 200M, "Gencho", new Battery(), new Display(5f, 1400000)); tests[2] = new GSM("3310", "Nokia", 30M, "Pesho", new Battery("CC23", 100000, 100000, BatteryType.NiMH), new Display()); tests[3] = new GSM("5115", "Nokia", 25M, "Gosho", new Battery("1234", 313, 233, BatteryType.NiCd), new Display(4f, 3131321)); foreach (var GSM in tests) { Console.WriteLine(GSM); } }
static void GSMTest() { GSM[] phones = new GSM[5]; phones[0] = new GSM("LG", "G2", 500, "Biggie Smalls", new Battery("AS/T29589-2014", 180, 13, BatteryType.NiMH), new Display(4, 16)); phones[1] = new GSM("Samsung", "S5", 420, "Tupac Shakur", new Battery("TU/U96548-2014", 200, 15, BatteryType.LiIon), new Display(5, 16)); phones[2] = new GSM("IPhone", "6S", 700, "Eminem", new Battery("KO/J74346-2015", 220, 11, BatteryType.LiIon), new Display(4.2, 16)); phones[3] = new GSM("Nokia", "Lumia 900", 450, "Dr. Dre", new Battery("PL/Y37539-2013", 190, 14, BatteryType.NiCd), new Display(4.7, 16)); phones[4] = new GSM("Samsung", "S6", 600, "Eazy E", new Battery("BG/S65575-2014", 200, 12, BatteryType.NiMH), new Display(5.5, 16)); foreach (var phone in phones) { Console.WriteLine(phone); Console.WriteLine(new string('-', 50)); } Console.WriteLine(); Console.WriteLine("Printing the static IPhone4S:"); Console.WriteLine(); Console.WriteLine(GSM.IPhone4S); }
public void CallHistoryTest() { var peshoPhone = new GSM("HD2", "HTC", 100000M, "Pesho", new Battery("PeshoBattery", 31231, 31312, BatteryType.LiIon), new Display(10f, 20000000)); peshoPhone.AddCall("739172937193", 105); peshoPhone.AddCall("0854646466464", 2000); peshoPhone.AddCall("0864646464", 15); peshoPhone.AddCall("0888556464", 62); peshoPhone.ShowHistory(); decimal peshoBill = peshoPhone.CalculateTotalPrice(0.37M); Console.WriteLine("{0} has to pay {1:F2}{2}", peshoPhone.Owner, peshoBill, RegionInfo.CurrentRegion.CurrencySymbol); peshoPhone.DeleteCall("0854646466464"); peshoPhone.ShowHistory(); peshoBill = peshoPhone.CalculateTotalPrice(0.37M); Console.WriteLine("{0} has to pay {1:F2}{2}", peshoPhone.Owner, peshoBill, RegionInfo.CurrentRegion.CurrencySymbol); peshoPhone.ClearCallHistory(); peshoPhone.ShowHistory(); }
public static void Test() { GSM gsmNote = new GSM("Note 7", "Samsung", 1000M, "Viktor", new Battery("Samsung", 100, 40, BatteryType.LiIon), new Display(1024, 1024)); gsmNote.AddCall(new Call()); GSM gsmHtc = new GSM("OneTouch", "HTC", 9000M, "Ivan", new Battery("HTC", 105, 43, BatteryType.NiCd), new Display(1024, 1024)); GSM[] gsms = new GSM[] { gsmNote, gsmHtc, GSM.IPhone4S }; foreach (GSM gsm in gsms) { Console.WriteLine(gsm); } }
public static void GSMTestMethod() { // Create some GSM instances Battery battery = new Battery("samsung", 10, 5, BatteryType.Lion); Display display = new Display(new Pair(400, 800), 16000000); GSM gsm1 = new GSM("Lumia", "Nokia", 0, "me", battery, display); GSM gsm2 = new GSM("Galaxy III", "Samsung"); GSM gsm3 = new GSM(); // Create array of phones GSM[] gsmArray = new GSM[] { gsm1, gsm2, gsm3 }; // Print the phones for (int i = 0; i < gsmArray.Length; i++) { Console.WriteLine(gsmArray[i]); Console.WriteLine("\n-----------------------------"); } // Print the IPhone4S static variable Console.WriteLine(GSM.GetIPhone4S()); }
static GSM() //problem 6 { IPhone4S = new GSM("iPhone4S", "Apple", 800.00m, "Me", new Battery("579C-E2380", 200.00, 10.00, BatteryTypes.LiIon), new Display(3.5, 16000000)); }
public GSMCallHistoryTest() { gsmDevice = new GSM("One M8", "HTC"); }