public static void TestAddCalls(GSM testPhone) { testPhone.AddCall(new DateTime(2014, 12, 21, 8, 3, 14), "Pesho", 14); //add some calls testPhone.AddCall(new DateTime(2014, 12, 21, 8, 43, 12), "Gosho", 218); testPhone.AddCall(new DateTime(2014, 12, 21, 18, 14, 43), "Stamat", 32); testPhone.AddCall(new DateTime(2014, 12, 21, 12, 54, 53), "Hasan", 5); }
public static void testCallHistory() { GSM testGSM = new GSM("Vibe Shor z90", "Lenovo", 199.99m, "Joro", new Battery("Chinese", 208.5f, 13.8f, BatteryType.LiPol), new Display("1920x1080", "16M")); testGSM.AddCall(new Call(DateTime.Now, "+359898987413", 85)); testGSM.AddCall(new Call(new DateTime(2016, 03, 17, 15, 43, 27), "+359898257413", 185)); testGSM.AddCall(new Call(new DateTime(2016, 03, 18, 15, 43, 27), "+3598981234563", 560)); testGSM.AddCall(new Call(new DateTime(2016, 02, 18, 15, 43, 27), "+359898987413", 85)); Call longestCall = testGSM.callHistory[0]; foreach (var call in testGSM.callHistory) { Console.WriteLine(call); if (longestCall.Duration < call.Duration) { longestCall = call; } } Console.WriteLine(testGSM.CallsPrice()); testGSM.RemoveCall(longestCall); Console.WriteLine(testGSM.CallsPrice()); testGSM.PrintCallHistory(); testGSM.ClearCalls(); testGSM.PrintCallHistory(); }
static void Main() { GSM gg = new GSM("sony", "az"); Battery bat = new Battery(); bat.BatteryType = }
public static void TestGSM() { var battery = new Battery("Moqta firma za baterii", "Moqt model bateriq", 100, 150, BatteryType.LiIon); var display = new Display("Moqta firma za displejove", "Moqt model display", 5.6, "1900 x 600"); var gsm = new GSM("Moqta firma", "Moqt model", battery, display, "Az sym owner", 1900); var gsmToString = gsm.ToString(); Console.WriteLine(gsmToString); }
static void Main() { Battery myBattery = new Battery("B. M.", 15, 56, BatteryType.NiMH); Battery myBattery1 = new Battery("B. M.", 17, 68, BatteryType.LiIon); Battery myBattery2 = new Battery("B. M.", 16, 69, BatteryType.NiCd); GSM gsm = new GSM("S6", "Samsung", 500.03m, "Pesho", myBattery); Console.WriteLine(gsm + "\n"); Console.WriteLine(GSM.IPhone + "\n"); GSM gsm1 = new GSM("S1", "Samsung", 100.09m, "Pesho", myBattery); GSM gsm2 = new GSM("S2", "Samsung", 200.09m, "Pesho", myBattery1); GSM gsm3 = new GSM("S3", "Samsung", 300.09m, "Pesho", myBattery2); GSM gsm4 = new GSM("S4", "Samsung", 400.09m, "Pesho", myBattery1); List <GSM> gsmList = new List <GSM>() { gsm1, gsm2, gsm3, gsm4 }; foreach (var telephone in gsmList) { Console.WriteLine(telephone); } DateTime date1 = new DateTime(2008, 8, 29, 19, 27, 15, 18); DateTime date2 = new DateTime(2014, 8, 30, 19, 22, 15, 18); DateTime date3 = new DateTime(2014, 9, 15, 10, 12, 14, 44); CultureInfo ci = CultureInfo.InvariantCulture; Call call1 = new Call(date1, date1, "+359878864612", 120); Call call2 = new Call(date2, date2, "+359871164612", 820); Call call3 = new Call(date3, date3, "+359872264612", 320); gsm.AddCall(call1); gsm.AddCall(call2); gsm.AddCall(call3); var calls = gsm.GetCalls(); gsm.DisplayCallsInfo(); Console.WriteLine("\nTotal price of the calls in the history is {0} BGN\n", gsm.CallPrice()); var longestCall = calls.OrderByDescending(x => x.CallDurationInSeconds).First(); gsm.DeleteCall(longestCall); Console.WriteLine("Phone call deleted"); Console.WriteLine("\nTotal price of the calls in the history is {0} BGN\n", gsm.CallPrice()); gsm.ClearCallHistory(); gsm.DisplayCallsInfo(); }
public static void PrintGSMsInfo(GSM[] gsms) { for (int i = 0; i < gsms.Length; i++) { Console.WriteLine("GSM {0}", gsms[i]); Console.WriteLine(); } Console.WriteLine("IPhone info: {0}", GSM.Iphone4S); }
public static GSM[] GenerateGSMs(int number) { GSM[] gsms = new GSM[number]; for (int i = 0; i < number; i++) { gsms[i] = new GSM(manifacturer[r.Next(0, manifacturer.Length)], model[r.Next(0, model.Length)], r.Next(1, 1000), owner, new Battery(), new Display()); } return gsms; }
public static void Test() { GSM[] arr = new GSM[]{new GSM("One X", "HTC", 800, "Georgi", new Battery("Li/Ion", 200, 7), new Display(4.7, 160000000)), new GSM ("Lumia 800", "Nokia")}; for (int i = 0; i < arr.Length; i++) { Console.WriteLine(arr[i].ToString()); Console.WriteLine(); } Console.WriteLine(GSM.Iphone4S); Console.WriteLine(); }
static void Main(string[] args) { Display testDisplay = new Display("iPhone Display", "5'5", "16 million"); Battery testBattery = new Battery("iPhone Battery", "3000mAh", BatteryType.LiIon); Call callOne = new Call(DateTime.Today, 420); Call callTwo = new Call(DateTime.Today, 366); GSM iPhone = new GSM("Apple", "Iphone 7", 499.99m, testDisplay, testBattery); iPhone.AddCallToCallHistory(callOne); iPhone.AddCallToCallHistory(callTwo); iPhone.DisplayInfo(); }
//Task 7 private static void GSMTests() { GSM test1 = new GSM("N95", "Nokia"); GSM test2 = new GSM("Galaxy S3", "Samsung", 1200, "Az", new Battery(), new Display(), new List<Call>()); GSM test3 = new GSM("Xperia", "Sony", 1300, "Az", new Battery("A64", 50, 60, BatteryType.LithiumIonPolymer), new Display(4.8M, 32000), new List<Call>()); GSM[] gsms = { test1, test2, test3}; foreach (var gsm in gsms) { Console.WriteLine(gsm); Console.WriteLine(new string('-', 50)); } Console.WriteLine(GSM.IPhone4S); }
static void Main() { Battery myBattery = new Battery("B. M.", 15, 56, BatteryType.NiMH); Battery myBattery1 = new Battery("B. M.", 17, 68, BatteryType.LiIon); Battery myBattery2 = new Battery("B. M.", 16, 69, BatteryType.NiCd); GSM gsm = new GSM("S6", "Samsung", 500.03m, "Pesho", myBattery); Console.WriteLine(gsm + "\n"); Console.WriteLine(GSM.IPhone + "\n"); GSM gsm1 = new GSM("S1", "Samsung", 100.09m, "Pesho", myBattery); GSM gsm2 = new GSM("S2", "Samsung", 200.09m, "Pesho", myBattery1); GSM gsm3 = new GSM("S3", "Samsung", 300.09m, "Pesho", myBattery2); GSM gsm4 = new GSM("S4", "Samsung", 400.09m, "Pesho", myBattery1); List<GSM> gsmList = new List<GSM>() { gsm1, gsm2, gsm3, gsm4 }; foreach (var telephone in gsmList) { Console.WriteLine(telephone); } DateTime date1 = new DateTime(2008, 8, 29, 19, 27, 15, 18); DateTime date2 = new DateTime(2014, 8, 30, 19, 22, 15, 18); DateTime date3 = new DateTime(2014, 9, 15, 10, 12, 14, 44); CultureInfo ci = CultureInfo.InvariantCulture; Call call1 = new Call(date1, date1, "+359878864612", 120); Call call2 = new Call(date2, date2, "+359871164612", 820); Call call3 = new Call(date3, date3, "+359872264612", 320); gsm.AddCall(call1); gsm.AddCall(call2); gsm.AddCall(call3); var calls = gsm.GetCalls(); gsm.DisplayCallsInfo(); Console.WriteLine("\nTotal price of the calls in the history is {0} BGN\n", gsm.CallPrice()); var longestCall = calls.OrderByDescending(x => x.CallDurationInSeconds).First(); gsm.DeleteCall(longestCall); Console.WriteLine("Phone call deleted"); Console.WriteLine("\nTotal price of the calls in the history is {0} BGN\n", gsm.CallPrice()); gsm.ClearCallHistory(); gsm.DisplayCallsInfo(); }
static void gsm_OnNetworkRegisterChange(GSM.GSM_Status Status) { if (Status == GSM.GSM_Status.NotRegisteredNotSearching) Debug.Print("Not Registered Not Searching"); else if (Status == GSM.GSM_Status.NotRegisteredSearching) Debug.Print("Not Registered, Searching"); else if (Status == GSM.GSM_Status.Registered) Debug.Print("Registered"); else if (Status == GSM.GSM_Status.RegisteredRoaming) Debug.Print("Registered - Roaming"); else if (Status == GSM.GSM_Status.RegistrationDenied) Debug.Print("Registration Denied."); else Debug.Print("unknonw.."); }
public static void TestCallHistory() { var battery = new Battery("Moqta firma za baterii", "Moqt model bateriq", 100, 150, BatteryType.LiIon); var display = new Display("Moqta firma za displejove", "Moqt model display", 5.6, "1900 x 600"); var gsm = new GSM("Moqta firma", "Moqt model", battery, display, "Az sym owner", 1900); for (int i = 0; i < 10; i++) { gsm.AddCall(new Call(DateTime.Now.ToString(), i, "087830" + i)); } gsm.RemoveLastCall(); Console.WriteLine(gsm.CallBill(1)); gsm.ClearCallHistory(); Console.WriteLine(gsm.CallBill(1)); }
public static void GSMTestTest() { Console.WriteLine("GSMTest:"); GSM[] arrGSM = new GSM[3]; arrGSM[0] = new GSM("Galaxy Gio", "Samsung", 320); arrGSM[1] = new GSM("Google Nexus 4", "LG", 700); arrGSM[2] = new GSM("5330M", "Nokia", 180); foreach (var gsm in arrGSM) { Console.WriteLine("{0} {1} is worth ${2} and is own by {3}", gsm.Manufacturer, gsm.Model, gsm.Price, gsm.Owner); } Console.WriteLine(); Console.WriteLine("{0} {1} is worth ${2} and is own by {3}", GSM.IPhone4S.Manufacturer, GSM.IPhone4S.Model, GSM.IPhone4S.Price, GSM.IPhone4S.Owner); }
public static void GenerateGSMs() { GSM htc = new GSM("One", "HTC", 750m, "Sasho", new Battery("Li-Ion", 500, 18, BatteryType.LiIon), new Display(4.7, 16000000)); GSM samsung = new GSM("S5", "Samsung", 1000m, "Mariya", new Battery("Li-Ion", 390, 21, BatteryType.LiIon), new Display(5.1, 16000000)); GSM sony = new GSM("Xperia Z3", "Sony", 900m, "Gergana", new Battery("Li-Ion", 740, 16, BatteryType.LiIon), new Display(5.2, 16000000)); GSM nokia = new GSM("Lumia 930", "Nokia", 540m, "Todor", new Battery("Li-Ion", 432, 11, BatteryType.LiIon), new Display(5.0, 16000000)); GSM[] gsmArray = new GSM[] { htc, samsung, sony, nokia, GSM.Iphone4S }; foreach (var gsm in gsmArray) { Console.WriteLine(gsm.ToString()); Console.WriteLine(); } }
public static void Test() { Console.WriteLine("Problem 7. GSM test" + Environment.NewLine); var arrGsm = new GSM[] { GSM.Iphone4S, new GSM("Samsung", "Galaxy"), new GSM("HTC", "Whatever"), GSM.Iphone4S }; foreach (var gsm in arrGsm) { Console.WriteLine(gsm.ToString()); } Console.WriteLine(GSM.Iphone4S.ToString()); }
public static void GenerateCallHistory() { // Create an instance of the GSM class GSM myGSM = new GSM("G2", "LG", 560m, "Pesho", new Battery("Li-Po", 790, 16, BatteryType.LiIon), new Display(5.2, 16000000)); //Add few calls myGSM.AddCall(new Call(new DateTime(2015, 3, 10, 20, 53, 20), "0881234567", 65)); myGSM.AddCall(new Call(new DateTime(2015, 3, 9, 15, 25, 47), "0889876543", 130)); myGSM.AddCall(new Call(new DateTime(2015, 3, 7, 11, 47, 10), "0891112223", 239)); myGSM.AddCall(new Call(new DateTime(2015, 2, 28, 19, 37, 32), "0988854321", 167)); // Display the information about the calls myGSM.PrintCallHistory(); // Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history decimal totalPriceOfCalls = myGSM.CalculateCallsPrice(0.37m); Console.WriteLine("Total price of calls in the history: {0:0.00}", totalPriceOfCalls); // Remove the longest call from the history and calculate the total price again Call longestCall = myGSM.CallHistory[0]; foreach (Call call in myGSM.CallHistory) { if (call.Duration > longestCall.Duration) { longestCall = call; } } myGSM.DeleteCall(longestCall); totalPriceOfCalls = myGSM.CalculateCallsPrice(0.37m); Console.WriteLine("Total price of calls in the history after removing the longest call: {0:0.00} \n", totalPriceOfCalls); // Finally clear the call history and print it myGSM.ClearCallHistory(); myGSM.PrintCallHistory(); }
static void Main() { Console.WriteLine("First test."); GSMTest.GSMTestTest(); Console.WriteLine(); Console.WriteLine("CallHistoryTest:"); GSM testPhone = new GSM("X", "HTC"); GSMCallHistoryTest.TestAddCalls(testPhone); GSMCallHistoryTest.TestPrintCalls(testPhone); GSMCallHistoryTest.TestCalcBill(testPhone, 0.37); GSMCallHistoryTest.TestRemoveLongestCall(testPhone); GSMCallHistoryTest.TestCalcBill(testPhone, 0.37); GSMCallHistoryTest.TestClearCalls(testPhone); GSMCallHistoryTest.TestPrintCalls(testPhone); }
public static void Calls() { GSM myGsm = new GSM("One X", "HTC", 800, "Georgi", new Battery("Li/Ion", 200, 7), new Display(4.7, 160000000)); myGsm.AddCall("0878182854", 213); myGsm.AddCall("0898625311", 51); myGsm.AddCall("0898694325", 118); foreach (var item in myGsm.GetCallHistory) { Console.WriteLine("Call to: "+item.phoneNumber); Console.WriteLine("Duration: "+item.duration); Console.WriteLine("Date: "+item.date); Console.WriteLine(); } Console.WriteLine("Total price: {0}", myGsm.TotalPriceOfCalls(0.37)); //Remove the longest call int max=0; int index=0; foreach (var item in myGsm.GetCallHistory) { if (item.duration > max) { max = item.duration; index = myGsm.GetCallHistory.IndexOf(item); } } GSM.callHistory.RemoveAt(index); Console.WriteLine("Total price: {0}", myGsm.TotalPriceOfCalls(0.37)); //Clear all history and print it myGsm.ClearAllCallHistory(); foreach (var item in myGsm.GetCallHistory) { Console.WriteLine("Call to: " + item.phoneNumber); Console.WriteLine("Duration: " + item.duration); Console.WriteLine("Date: " + item.date); Console.WriteLine(); } }
static GSM() { iphone4S = new GSM("iPhone4S", "Apple"); }
private decimal price; //Task 1 #endregion Fields #region Constructors static GSM() { IPhone4S = new GSM("4S", "iPhone", 1000.0M, "Az", new Battery(), new Display(), new List<Call>()); }
public static void TestPrintCalls(GSM testPhone) { testPhone.PrintCalls(); }
public static void TestCalcBill(GSM testPhone, double pricePerMin) { double bill = testPhone.CalcBill(pricePerMin); Console.WriteLine("Your bill is: {0:C}",bill); }
public static void TestRemoveLongestCall(GSM testPhone) { testPhone.RemoveLongestCall(); }
public static void TestClearCalls(GSM testPhone) { testPhone.ClearCalls(); }
public void SendEmail(string Text, string Subject, string Address, GSM.MessageCenter.SendEmailDelegate callback, Object OriginalMessage) { try { SmtpClient SMTPClient = new SmtpClient(SmtpServer, SmtpPort); string server = SmtpServer; string username = Email; string password = Password; int port = SmtpPort; SMTPClient.EnableSsl = SmtpSSL; SMTPClient.DeliveryMethod = SmtpDeliveryMethod.Network; SMTPClient.Host = server; SMTPClient.UseDefaultCredentials = false; SMTPClient.Credentials = new NetworkCredential(username, password); System.Net.Mail.MailAddress from = new System.Net.Mail.MailAddress(username, "Оцени-сервис", System.Text.Encoding.UTF8); System.Net.Mail.MailAddress to = new System.Net.Mail.MailAddress(Address); System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(from, to); message.Body = Text; message.IsBodyHtml = false; message.BodyEncoding = System.Text.Encoding.UTF8; message.Subject = Subject; message.SubjectEncoding = System.Text.Encoding.UTF8; SMTPClient.SendCompleted += new SendCompletedEventHandler(callback); SMTPClient.SendAsync(message, OriginalMessage); } catch (Exception e) { logger.Error("Ошибка при отправке сообщения с почтового ящика " + (Email ?? "") + ".\r\nАдрес сервера:" + (SmtpServer?? "") + ".\r\nУдаленный порт: " + SmtpPort + "\r\nШифрование:" + (ImapSSL ? "Включено" : "Выключено") + "\r\nТекст ошибки:" ,e); } }
static void Main() { const int TestLenOfArray = 10; //max length of test array List<GSM> testGSMArray = new List<GSM>(); // declare test array of instances of the GSM class Battery newBattery = new Battery("C6603", 530, 11, BatteryType.LiIon); // create instance of Battery class Display newDisplay = new Display(5, 16000000); // create instance of Display class //initialize testGSMArray for (int i = 0; i < TestLenOfArray; i++) { GSM gsm = new GSM("Xperia Z", "Sony", 680.00m, "Pesho", newBattery, newDisplay); testGSMArray.Add(gsm); } testGSMArray[0].Owner = "Gogo"; //test throw exception //testGSMArray[0].Price = -1000; //test throw exception //newBattery.HoursTalk = -1; //test GSM for (int i = 0; i < TestLenOfArray; i++) { Console.WriteLine("_________________________________________"); testGSMArray[i].PrintAllInfoGSM(); Console.WriteLine("_________________________________________"); } GSM newGsm = new GSM("Xperia Z", "Sony", 680.00m, "Tosho", newBattery, newDisplay); Console.WriteLine(newGsm.IPhone4S); //TODO method for printing static property //test calls Call firstCall = new Call("+359888445522", 300); Call secondCall = new Call("+359888445521", 800); Call thirdCall = new Call("+359888445523", 700); Console.WriteLine("Calls History:"); testGSMArray[0].AddCallsINHistory(firstCall); Console.Write("Price:{0} BGN ", testGSMArray[0].ClacPriceofCalls(firstCall)); Console.WriteLine(testGSMArray[0].CallHistory[0].ToString()); testGSMArray[0].AddCallsINHistory(secondCall); Console.Write("Price:{0} BGN ", testGSMArray[0].ClacPriceofCalls(secondCall)); Console.WriteLine(testGSMArray[0].CallHistory[1].ToString()); testGSMArray[0].AddCallsINHistory(thirdCall); Console.Write("Price:{0} BGN ", testGSMArray[0].ClacPriceofCalls(thirdCall)); Console.WriteLine(testGSMArray[0].CallHistory[2].ToString()); decimal totalBill = 0.0m; for (int i = 0; i < testGSMArray[0].CallHistory.Count; i++) { totalBill += testGSMArray[0].ClacPriceofCalls(testGSMArray[0].CallHistory[i]); } Console.WriteLine("Total Bill:{0}", totalBill); uint maxDuration = 0; string maxDurCallId = String.Empty; //TODO method for calc total price for (int i = 0; i < testGSMArray[0].CallHistory.Count-1; i++) { if(testGSMArray[0].CallHistory[i].CallDuration > maxDuration) { maxDuration = testGSMArray[0].CallHistory[i].CallDuration; maxDurCallId = testGSMArray[0].CallHistory[i].Id; } } Console.WriteLine("_____________"); testGSMArray[0].DeleteCallsHistory(maxDurCallId); testGSMArray[0].PrintCallHistory(); totalBill = 0.0m; for (int i = 0; i < testGSMArray[0].CallHistory.Count; i++) { totalBill += testGSMArray[0].ClacPriceofCalls(testGSMArray[0].CallHistory[i]); } Console.WriteLine("Total bill without longest call:{0}", totalBill); Console.WriteLine("_____________"); testGSMArray[0].ClearCallsHistory(); testGSMArray[0].PrintCallHistory(); }