public static void Test() { Console.WriteLine(); Console.WriteLine("GSM Call History Test:"); GSM myGSM = new GSM("C2-01", "Nokia"); DateTime date = new DateTime(); TimeSpan time = new TimeSpan(); date = DateTime.Now.Date; time = DateTime.Now.TimeOfDay; myGSM.AddCall(date, time, 98325, 33); myGSM.AddCall(date.AddDays(2), time, 111111, 67); myGSM.AddCall(date.AddDays(7), time, 324624, 50); int maxIndex = 0; for (int index = 0; index < myGSM.CallHistory.Count; index++) { if (myGSM.CallHistory[maxIndex].Duration < myGSM.CallHistory[index].Duration) { maxIndex = index; } Console.WriteLine(myGSM.CallHistory[index].ToString()); } Console.WriteLine(); Console.Write("The total price for all calls is: {0}$", myGSM.CalculatePrice(0.37m)); Console.WriteLine(); Console.WriteLine("The longest call duration is {0}",myGSM.CallHistory[maxIndex].ToString()); myGSM.DeleteCall(maxIndex); Console.WriteLine("The new price without the longest call is: {0}$",myGSM.CalculatePrice(0.37m)); myGSM.ClearCallHistory(); }
static void Main() { try { //initializing new gsm GSM MyGSM = new GSM("Monte", "Samsung", 10, "Pesho", "DINO", 10, 6, BatteryType.LiIon, 7, 256000); //setting static field value GSM.IPhone = "This is some information for IPhone4S"; //Perform calls MyGSM.PerformCall(new DateTime(2013, 2, 3), DateTime.Now, "0898654793", 300); MyGSM.PerformCall(new DateTime(2013, 2, 7), DateTime.Now, "0898654703", 600); MyGSM.PerformCall(new DateTime(2013, 2, 13), DateTime.Now, "0898254793", 200); MyGSM.PerformCall(new DateTime(2013, 2, 15), DateTime.Now, "0898647793", 100); MyGSM.PerformCall(new DateTime(2013, 2, 16), DateTime.Now, "0898251793", 1300); //display history Console.WriteLine(MyGSM.DisplayCallHistory()); //calculate and display calls price Console.WriteLine("Calls price is {0:C}\n", MyGSM.CalculateCallsPrice((decimal)0.37)); //delete history record MyGSM.DeleteCall("0898251793"); //calculate and display calls price again Console.WriteLine("Calls price is {0:C}\n", MyGSM.CalculateCallsPrice((decimal)0.37)); //display history again Console.WriteLine(MyGSM.DisplayCallHistory()); //clear history MyGSM.ClearHistory(); //display history again Console.WriteLine(MyGSM.DisplayCallHistory()); //displaing info Console.WriteLine(MyGSM); //getting static field value Console.WriteLine(GSM.IPhone); } catch(ArgumentException ae) { Console.WriteLine(ae.Message); } }