示例#1
0
        public void TestCalls()
        {
            gsm.AddCall("5/1/2008 8:30:52 AM", 2030, 120);
            gsm.AddCall("6/1/2008 10:50:52 AM", 3040, 360);
            gsm.AddCall("7/1/2008 11:33:52 AM", 4050, 200);

            PrintDetails(gsm);

            Console.WriteLine("Total Call Cost: {0:0.00}$\n", gsm.GetCallsCost(0.37f));

            float longestDuration = gsm.CallHistory[0].CallDurationInSeconds;

            for (int i = 1; i < gsm.CallHistory.Count; i++)
            {
                if (gsm.CallHistory[i].CallDurationInSeconds > longestDuration)
                {
                    longestDuration = gsm.CallHistory[i].CallDurationInSeconds;
                }
            }

            gsm.RemoveCall(longestDuration);
            Console.WriteLine("Total Call Cost After Longest Call Removal: {0:0.00}$\n", gsm.GetCallsCost(0.37f));
            gsm.ClearCallHistory();
            Console.WriteLine("Now cleared\n");
            PrintDetails(gsm);
        }
        static void Main()
        {
            GSM mobile = new GSM("Samsung", "Galaxy S5360", 330, "Evgeni Velikov");

            mobile.AddCall(new Call(300));
            mobile.AddCall(new Call(4000));
            mobile.AddCall(new Call(120));

            Console.WriteLine("Total Price: {0:C}", mobile.CalculateTotalPrice());

            mobile.RemoveCall(new Call(4000));

            Console.WriteLine("Total Price After Remove: {0:C}", mobile.CalculateTotalPrice());

            mobile.RemoveAllCall();

            Console.WriteLine("Remove Total Price: {0:C}", mobile.CalculateTotalPrice());

            Console.WriteLine();

            mobile.battery.HoursIdle = 340;
            mobile.battery.HoursTalk = 12;
            mobile.battery.Model = BatteryType.Li_Ion;
            mobile.display.Size = "320x480";
            mobile.display.Colors = 65895;

            Console.WriteLine(mobile);
        }
示例#3
0
        public static void Main()
        {
            var gsms = new List<GSM>
            {
                new GSM("Galaxy 6", "Samsung", 800.00m, new Battery(BatteryType.LiIon, "model", 500, 100), new Display(5.3)),
                new GSM("6", "IPhone", 1200.00m, new Battery(BatteryType.LiIon, "model", 800, 400), new Display()),
                new GSM("Model", "LG", 400.00m, new Battery(BatteryType.NiCd, "model", 300, 100), new Display(4.5)),
                new GSM("Lumia 930", "Nokia", 500.00m, new Battery(BatteryType.NiMH, "model 3", 400, 200), new Display()),
                new GSM("Neshto si", "Sony", 450.00m, new Battery(BatteryType.NiCd, "model", 343, 140), new Display(4.8)),
                new GSM("Galaxy 4", "Samsung", 550.00m, new Battery(BatteryType.LiIon, "model", 400, 150), new Display())
            };

            foreach (var gsm in gsms)
            {
                Console.WriteLine(gsm);
            }

            Console.WriteLine(GSM.iPhone4s);

            var testCallsGsm = new GSM();
            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(234), "+359888787878"));
            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(434), "+35988865161"));
            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(2234), "+359887846163"));
            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(624), "+359885525056"));
            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(12352), "+359884651625"));

            Console.WriteLine("Before removing the longest call from call history the price is - {0:F2}", testCallsGsm.CalculatePrice(0.37));

            var longestcall = testCallsGsm.CallHistory.OrderByDescending(x => x.Length).FirstOrDefault();
            testCallsGsm.CallHistory.Remove(longestcall);
            Console.WriteLine("After removing the longest call from call history the price is - {0:F2}", testCallsGsm.CalculatePrice(0.37));
            testCallsGsm.ClearHistory();
            Console.WriteLine("After removing all the calls from call history the price is - {0:F2}", testCallsGsm.CalculatePrice(0.37));
        }
        public static void GSMCallHistoryTestMethod()
        {
            Console.WriteLine("\n------------------------------------");
            Console.WriteLine("        Call History Test!");
            Console.WriteLine("------------------------------------\n");

            GSM phone = new GSM("Galaxy S 3", "Samsung");

            phone.AddCall(new Call(DateTime.Parse("6/12/2009 07:23:00 AM"), "0888123456") { Duration = 31 });
            phone.AddCall(new Call(DateTime.Parse("10/11/2010 10:44:00 AM"), "0888678910") { Duration = 360 });
            phone.AddCall(new Call(DateTime.Parse("7/05/2012 06:56:00 PM"), "0888111213") { Duration = 600 });

            PrintCalls(phone);

            //Get longest call.
            var maxCall =
                (from call in phone.CallHistory
                 orderby call.Duration descending
                 select call).First();

            //Delete longest call.
            phone.DeleteCall(phone.CallHistory.IndexOf(maxCall));

            PrintCalls(phone);

            //Clear all calls.
            phone.ClearHistory();

            PrintCalls(phone);
        }
示例#5
0
        static void Main()
        {
            GSM mobile = new GSM("Samsung", "Galaxy S5360", 330, "Evgeni Velikov");

            mobile.AddCall(new Call(300));
            mobile.AddCall(new Call(4000));
            mobile.AddCall(new Call(120));

            Console.WriteLine("Total Price: {0:C}", mobile.CalculateTotalPrice());

            mobile.RemoveCall(new Call(4000));

            Console.WriteLine("Total Price After Remove: {0:C}", mobile.CalculateTotalPrice());

            mobile.RemoveAllCall();

            Console.WriteLine("Remove Total Price: {0:C}", mobile.CalculateTotalPrice());

            Console.WriteLine();

            mobile.battery.HoursIdle = 340;
            mobile.battery.HoursTalk = 12;
            mobile.battery.Model     = BatteryType.Li_Ion;
            mobile.display.Size      = "320x480";
            mobile.display.Colors    = 65895;

            Console.WriteLine(mobile);
        }
示例#6
0
        public string CalculatePrice()
        {
            GSM someGSM = new GSM(Manufacturer.APPLE, "Iphone4S");

            someGSM.AddCall(new Call(DateTime.Now, "0889", 200));
            someGSM.AddCall(new Call(DateTime.Now, "0886", 400));
            someGSM.AddCall(new Call(DateTime.Now, "0887", 430));

            decimal totalPrice = someGSM.TotalCallPrice(0.37M);
            return string.Format("{0:C}", totalPrice);
        }
        static void Main()
        {
            // create test GSM
            string delimiter  = new string('\xA', 3) + new string('-', 35);
            GSM    genericGsm = new GSM("Test model", "Test manufacturer");

            // add calls
            var date1 = new DateTime(2014, 03, 10, 04, 55, 0);
            var date2 = new DateTime(2014, 03, 10, 13, 55, 0);
            var date3 = new DateTime(2014, 03, 10, 18, 55, 0);

            genericGsm.AddCall(new Call(date1, "+359885985678", 90));
            genericGsm.AddCall(new Call(date2, "+359885985678", 120));
            genericGsm.AddCall(new Call(date3, "+359885985678", 70));


            // display calls
            Console.WriteLine("DISPLAY ALL CALLS");
            PrintCallHistory("\nNEXT CALL\n", genericGsm);


            // calculate total price of calls
            Console.WriteLine(delimiter);
            Console.WriteLine("CALCULATE TOTAL BILL");
            Console.WriteLine("Total Bill: {0:0.00}", genericGsm.TotalCallsBill());


            // remove longest call
            Console.WriteLine(delimiter);
            Console.WriteLine("REMOVE LONGEST CALL");
            int maxDuration      = 0;
            int maxDurationIndex = 0;

            for (int i = 0; i < genericGsm.CallHistory.Count; i++)
            {
                if (genericGsm.CallHistory[i].Duration > maxDuration)
                {
                    maxDuration      = genericGsm.CallHistory[i].Duration;
                    maxDurationIndex = i;
                }
            }

            genericGsm.DeleteCall(maxDurationIndex);
            Console.WriteLine("CALCULATE TOTAL BILL");
            Console.WriteLine("Total Bill: {0:0.00}", genericGsm.TotalCallsBill());


            // clear call history and print
            Console.WriteLine(delimiter);
            Console.WriteLine("CLEAR CALL HISTORY AND PRINT");
            genericGsm.ClearCalls();
            PrintCallHistory(delimiter, genericGsm);
        }
示例#8
0
        public string CalculatePrice()
        {
            GSM someGSM = new GSM(Manufacturer.APPLE, "Iphone4S");

            someGSM.AddCall(new Call(DateTime.Now, "0889", 200));
            someGSM.AddCall(new Call(DateTime.Now, "0886", 400));
            someGSM.AddCall(new Call(DateTime.Now, "0887", 430));

            decimal totalPrice = someGSM.TotalCallPrice(0.37M);

            return(string.Format("{0:C}", totalPrice));
        }
        public static void GSMCallHistoryTest()
        {
            GSM testCalls = new GSM("WildFire", "HTC", 150, "Ivan", new Battery(BatteryType.LiIon));

            testCalls.AddCall(new DateTime(2015, 7, 26, 15, 15, 26), "+359889653420", 88);
            testCalls.AddCall(new DateTime(2015, 7, 26, 16, 16, 16), "+359824568420", 64);
            testCalls.AddCall(new DateTime(2015, 7, 26, 15, 31, 59), "+359862487258", 1360);
            testCalls.AddCall(new DateTime(2015, 7, 26, 16, 0, 10), "+359883426864", 366);

            Console.WriteLine("Call history");

            foreach (var item in testCalls.CallHistory)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("Total price for all calls:{0}", testCalls.CallPrice((decimal)0.37));
            Console.WriteLine();
            Console.WriteLine("After removing the longest call...");

            int longestIndex = 0;
            int time = 0;

            for (int i = 0; i < testCalls.CallHistory.Count; i++)
            {
                if (testCalls.CallHistory[i].Time > time)
                {
                    time = testCalls.CallHistory[i].Time;
                    longestIndex = i;
                }
            }

            testCalls.DeleteCall(longestIndex);

            foreach (var item in testCalls.CallHistory)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("Total price of call history:{0}", testCalls.CallPrice(0.37m));
            Console.WriteLine("Deleting the call history...");
            testCalls.CallHistoryClear();
            Console.WriteLine();
            Console.WriteLine("Call history:");

            foreach (var item in testCalls.CallHistory)
            {
                Console.WriteLine(item);
            }
        }
示例#10
0
        public string TestCallsAdding()
        {
            GSM myGSM = new GSM(Manufacturer.NOKIA, "3310");

            myGSM.AddCall(new Call(DateTime.Now, "0889", 200));
            myGSM.AddCall(new Call(DateTime.Now, "0886", 300));

            StringBuilder result = new StringBuilder();

            foreach (var call in myGSM.Calls)
            {
                result.AppendLine(call.ToString());
            }
            return result.ToString();
        }
示例#11
0
        public string TestCallsAdding()
        {
            GSM myGSM = new GSM(Manufacturer.NOKIA, "3310");

            myGSM.AddCall(new Call(DateTime.Now, "0889", 200));
            myGSM.AddCall(new Call(DateTime.Now, "0886", 300));

            StringBuilder result = new StringBuilder();

            foreach (var call in myGSM.Calls)
            {
                result.AppendLine(call.ToString());
            }
            return(result.ToString());
        }
        public void Test()
        {
            gsm.AddCall(new Call(new DateTime(2016, 05, 15, 18, 30, 22), "0885 654 213", 100));
            gsm.AddCall(new Call(new DateTime(2015, 11, 22, 13, 45, 23), "0888 352 351", 100));
            gsm.AddCall(new Call(new DateTime(2016, 09, 19, 15, 30, 44), "0887 424 212", 100));

            Console.WriteLine(gsm.CallHistoryInfo());

            Console.WriteLine("Total price: {0:F2} BGN", gsm.CallPrice(0.37m));

            gsm.RemoveLongestCall();
            Console.WriteLine("Now the total price is {0:F2} BGN", gsm.CallPrice(0.37m));

            gsm.ClearCallHistory();
            Console.WriteLine(gsm.CallHistoryInfo());
        }
示例#13
0
        static void Main(string[] args)
        {
            //var model = Console.ReadLine();

            //var manufacturer = Console.ReadLine();

            //var price = decimal.Parse(Console.ReadLine());

            //var owner = Console.ReadLine();

            //GSM myGSM = new GSM(model, manufacturer, price, owner);

            //myGSM.MyBattery.Model = Console.ReadLine();

            //BatteryType type;
            //string inputType = Console.ReadLine();
            //var parsedType = Enum.TryParse(inputType, out type);

            //myGSM.MyBattery.Type = type;

            //Console.WriteLine(myGSM);
            GSMTest currTest = new GSMTest();

            Console.WriteLine(currTest.ToString());

            var model   = Console.ReadLine();
            var manu    = Console.ReadLine();
            GSM currGSM = new GSM(model, manu);

            currGSM.AddCall()
        }
示例#14
0
        public static void TestCallHistory()
        {
            GSM motorola = new GSM("nexus", "Motorola", 500, "comapny phone", new Battery(BatteryType.NiCd), new Display(5, 2000));
            GSM newBrand = new GSM("SSD", "MegaHyper");

            motorola.AddCall(new Call("12/03/2015", "05:34", "0889888888", 100));
            motorola.AddCall(new Call("02.02.2012", "12:34", "0999999999", 140));
            motorola.AddCall(new Call("12.30.2012", "00:34", "0999999999", 12));
            ShowCalls(motorola.calls);
            Console.WriteLine("The Total Price is {0}", motorola.CalculateTotalPrice());
            motorola.FindAndRemoveLongestCall();
            Console.WriteLine("Longest call now removed");
            Console.WriteLine("The Total Price is {0:F2}", motorola.CalculateTotalPrice());
            motorola.ClearHistory();
            Console.WriteLine("Call history deleted");
        }
        static void Main()
        {
            // create test GSM
            string delimiter = new string('\xA', 3) + new string('-', 35);
            GSM genericGsm = new GSM("Test model", "Test manufacturer");

            // add calls
            var date1 = new DateTime(2014, 03, 10, 04, 55, 0);
            var date2 = new DateTime(2014, 03, 10, 13, 55, 0);
            var date3 = new DateTime(2014, 03, 10, 18, 55, 0);
            genericGsm.AddCall(new Call(date1, "+359885985678", 90));
            genericGsm.AddCall(new Call(date2, "+359885985678", 120));
            genericGsm.AddCall(new Call(date3, "+359885985678", 70));

            // display calls
            Console.WriteLine("DISPLAY ALL CALLS");
            PrintCallHistory("\nNEXT CALL\n", genericGsm);

            // calculate total price of calls
            Console.WriteLine(delimiter);
            Console.WriteLine("CALCULATE TOTAL BILL");
            Console.WriteLine("Total Bill: {0:0.00}", genericGsm.TotalCallsBill());

            // remove longest call
            Console.WriteLine(delimiter);
            Console.WriteLine("REMOVE LONGEST CALL");
            int maxDuration = 0;
            int maxDurationIndex = 0;
            for (int i = 0; i < genericGsm.CallHistory.Count; i++)
            {
                if (genericGsm.CallHistory[i].Duration > maxDuration)
                {
                    maxDuration = genericGsm.CallHistory[i].Duration;
                    maxDurationIndex = i;
                }
            }

            genericGsm.DeleteCall(maxDurationIndex);
            Console.WriteLine("CALCULATE TOTAL BILL");
            Console.WriteLine("Total Bill: {0:0.00}", genericGsm.TotalCallsBill());

            // clear call history and print
            Console.WriteLine(delimiter);
            Console.WriteLine("CLEAR CALL HISTORY AND PRINT");
            genericGsm.ClearCalls();
            PrintCallHistory(delimiter, genericGsm);
        }
示例#16
0
        static void Main()
        {
            //create a test instance & add 3 calls
            var gsmTest = new GSM("nokia", "test model");

            gsmTest.AddCall(new Call(new DateTime(2015, 12, 31, 10, 00, 00), "0888123456", 61));
            gsmTest.AddCall(new Call(new DateTime(2016, 12, 31, 10, 15, 00), "0888666555", 333));
            gsmTest.AddCall(new Call(new DateTime(2017, 01, 01, 00, 00, 01), "0888123456", 60));


            //test call price calculations
            Console.WriteLine("Test call price calculation method\r\n==========================================");
            Console.WriteLine("Total Calls Count: {0}", gsmTest.CallHistory.Count);
            Console.WriteLine("Total Price: {0: 0.00}", gsmTest.CallPrice(0.37M));
            Console.WriteLine();

            //print initial state of the instance
            Console.WriteLine("Initial state of the gsmTest object\r\n==========================================\r\n{0}", gsmTest);

            //delete the longest call
            int indexLongestCall = -1;
            int maxSeconds       = 0;

            foreach (var call in gsmTest.CallHistory)
            {
                if (call.Duration > maxSeconds)
                {
                    maxSeconds = (int)call.Duration;
                    indexLongestCall++;
                }
            }
            gsmTest.DeleteCall(indexLongestCall);

            //print price without longest call
            Console.WriteLine("\r\nPrice calculation without the longest call\r\n==========================================");
            Console.WriteLine("Total Calls Count: {0}", gsmTest.CallHistory.Count);
            Console.WriteLine("Total Price: {0: 0.00}\r\n", gsmTest.CallPrice(0.37M));
            Console.WriteLine("gsmTest object without the longest call\r\n==========================================\r\n{0}", gsmTest);

            //print the final state of the instance

            //clear the history
            gsmTest.ClearHistory();

            Console.WriteLine("gsmTest object with cleared history\r\n==========================================\r\n{0}", gsmTest);
        }
示例#17
0
        static void Main()
        {
            GSM phone = new GSM("Z3", "Sony", 990, "Pippi Longstocking", "Sony 3100mAh", 93.8, 52.9, BatteryType.LiIon, 5.2, 16000000);
            phone.AddCall(new Call(DateTime.Now, "+359 (0) 894 733 124", 287));
            phone.AddCall(new Call(DateTime.Now, "+359 (0) 894 788 134", 123));
            phone.AddCall(new Call(DateTime.Now.AddDays(-12), "+359 (0) 894 733 114", 90));

            PrintCallHistory(phone);

            Console.WriteLine("The total price of all calls of {0} is {1} EUR!", phone.Owner, CalculateTotalCallPrice(phone.CallHistory, callPricePerMinute));

            Console.WriteLine("The total price of all calls without the longest call of {0} is {1} EUR!", phone.Owner, CalculateTotalCallPrice(RemoveLongestCall(phone.CallHistory), callPricePerMinute));

            phone.ClearCallHistory();

            PrintCallHistory(phone);
        }
        static void Main(string[] args)
        {
            //zad.7
            GSMTest.PrintInfo();

            //Create an instance of the GSM class.
            GSM myPhone = new GSM("N95", "Nokia");

            //Add few calls.
            Call call = new Call(DateTime.Now, "0883333333", 60);
            Call nextCall = new Call(new DateTime(2013,02,10,20,34,20), "+3592376541212", 120);
            myPhone.AddCall(call);
            myPhone.AddCall(nextCall);

            //Display the information about the calls.
            foreach (var c in myPhone.CallHistory)
            {
                Console.WriteLine(c);
            }

            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            Console.Write("The total price of the calls is: ");
            myPhone.PriceOfCalls(0.37m);

            //Remove the longest call from the history and calculate the total price again.
            Call longest = new Call();
            longest.Duration = 0;
            for (int i = 0; i < myPhone.CallHistory.Count; i++)
            {
                if (myPhone.CallHistory[i].Duration > longest.Duration)
                {
                    longest = myPhone.CallHistory[i];
                }
            }
            myPhone.RemoveCall(longest);
            Console.Write("The new price after removing longest call is: ");
            myPhone.PriceOfCalls(0.37m);

            //Finally clear the call history and print it.
            myPhone.ClearCallHistory();
            foreach (var c in myPhone.CallHistory)
            {
                Console.WriteLine(c);
            }
        }
示例#19
0
        static void Main(string[] args)
        {
            var ipPhone6 = new GSM(model: "IP-Phone6", manufacturer: "xApple");
            var salamSumng = new GSM(model: "Jalacxy7", manufacturer: "SalamSung");

            var listFromSmartPhones = new List<GSM>();
            listFromSmartPhones.Add(ipPhone6);
            listFromSmartPhones.Add(salamSumng);

            foreach (var phones in listFromSmartPhones)
            {
                Console.WriteLine(phones);
            }

            var iPhone4s = GSM.IPhone4s;


            var firstTestCall = new Call()
            {
                TimeStart = DateTime.Now,
                TimeEnd = DateTime.Now.AddMinutes(2),
                ItsIncomming = false,
                PhoneNumber = "0043123123"
            };

            var duration = firstTestCall.Duration();

            var secondTestCall = new Call()
            {
                TimeStart = DateTime.Now,
                TimeEnd = DateTime.Now.AddMinutes(3),
                ItsIncomming = false,
                PhoneNumber = "0043123123"
            };

            ipPhone6.AddCall(firstTestCall);
            ipPhone6.AddCall(secondTestCall);

            decimal pricePerMinute = 0.37M;
            var totalPrice = ipPhone6.CallPrice(pricePerMinute);

            Console.WriteLine("Total call price: " + totalPrice);
        }
        public static void StartGSMCallHistoryTest()
        {
            //add mobile phone for test
            Console.WriteLine("GSM for call history test\n");
            GSM testPhone = new GSM("Iphone 8", "", 1699.99m, "Georgi", new Battery(BatteryType.NiMH, 40, 800),
                                    new Display(5.2m, 32000000));

            //add calls made with the test phone
            testPhone.AddCall(DateTime.Today, DateTime.Today.AddSeconds(34));
            testPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(3).AddSeconds(20));
            testPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(5).AddSeconds(2));
            testPhone.AddCall(DateTime.Today, DateTime.Today.AddSeconds(24));
            testPhone.AddCall(DateTime.Now, DateTime.Now.AddMinutes(4));
            testPhone.AddCall(DateTime.Now, DateTime.Now.AddSeconds(57));
            testPhone.AddCall(DateTime.Now, DateTime.Now.AddSeconds(49));
            testPhone.AddCall(DateTime.Now, DateTime.Now.AddMinutes(7).AddSeconds(42));

            //print test phone info
            Console.WriteLine(testPhone);

            //calculate and print price for all calls made with the test phone
            decimal price = testPhone.CalculateAllCallsPrice(0.37m);

            Console.WriteLine("Price for all calls is: {0:f2} lv.\n", price);

            //removing call in position 5 in calls list
            testPhone.RemoveCall(5);
            foreach (Call call in testPhone.CallsList)
            {
                Console.WriteLine(call);
            }
            price = testPhone.CalculateAllCallsPrice(0.37m);
            Console.WriteLine("\nPrice for all calls is: {0:f2} lv.\n", price);

            //removing longest call in calls list
            testPhone.RemoveLongestCall();
            foreach (Call call in testPhone.CallsList)
            {
                Console.WriteLine(call);
            }
            price = testPhone.CalculateAllCallsPrice(0.37m);
            Console.WriteLine("\nPrice for all calls is: {0:f2} lv.\n", price);

            //removing all calls in calls list
            testPhone.RemoveAllCalls();
            foreach (Call call in testPhone.CallsList)
            {
                Console.WriteLine(call);
            }
            price = testPhone.CalculateAllCallsPrice(0.37m);
            Console.WriteLine("Price for all calls is: {0:f2} lv.\n", price);
        }
        public static void CallHistorySimulation()
        {
            GSM htcMini = new GSM("One mini", "HTC", 400, "Ivan", new Battery(BatteryType.LiPol, null, 400, 60), new Display(4.3, "16M"));

            htcMini.AddCall(DateTime.Today, DateTime.Today.AddMinutes(10), "1234567890");
            htcMini.AddCall(DateTime.Today, DateTime.Today.AddMinutes(20), "1234567890");
            htcMini.AddCall(DateTime.Today, DateTime.Today.AddSeconds(10), "1234567890");
            htcMini.AddCall(DateTime.Today, DateTime.Today.AddSeconds(0), "1234567890");
            htcMini.AddCall(DateTime.Today, DateTime.Today.AddSeconds(48), "1234567890");

            Console.WriteLine("Call history\n");
            Console.WriteLine(htcMini);
            Console.WriteLine("Total price: {0:F2}\n", htcMini.TotalAmountOfCalls(0.37));
            htcMini.DeleteLongestCall();
            Console.WriteLine("After remove longest call\n");
            Console.WriteLine(htcMini);
            Console.WriteLine("Total price: {0:F2}\n", htcMini.TotalAmountOfCalls(0.37));
            Console.WriteLine("After clear call history\n");
            htcMini.DeleteAllCalls();
            Console.WriteLine(htcMini);
        }
        public static void AddCalls(GSM gsm)
        {
            Call[] callArray = new Call[3];
            callArray[0] = new Call(DateTime.Now, "0889123456", 5);
            callArray[1] = new Call(DateTime.Now, "0889123455", 12);
            callArray[2] = new Call(DateTime.Now, "0878536897", 3);

            for (int index = 0; index < callArray.Length; index++)
            {
                gsm.AddCall(callArray[index]);
            }
        }
 static void Main()
 {
     GSM MyGSM = new GSM("Galaxy S4", "Samsung",750.00m,"Slavi");
     // create an instance of the GSM class to test the call history functionality
     MyGSM.AddCall(new Call(new DateTime(2013, 09, 24, 10, 33, 00), "0887551432", 133));
     MyGSM.AddCall(new Call(new DateTime(2013, 09, 24, 11, 54, 10), "0886113432", 63));
     MyGSM.AddCall(new Call(new DateTime(2013, 09, 24, 23, 11, 23), "0886113432", 234));
     MyGSM.AddCall(new Call(new DateTime(2013, 09, 25, 07, 30, 03), "+359887551432", 73));
     MyGSM.AddCall(new Call(new DateTime(2013, 09, 25, 10, 04, 27), "+359897143223", 105));
     MyGSM.AddCall(new Call(new DateTime(2013, 09, 26, 15, 10, 55), "0878751030", 15));
     //add few calls and prints call history
     MyGSM.PrintCallHistory();
     Console.WriteLine();
     Console.WriteLine("The total price for the calls is: {0} BGN", MyGSM.CalcTotalPriceCallHistory(0.37m));
     //finds the longest call index
     int maxDuration = -1;
     int maxIndex = -1;
     for (int i = 0; i < MyGSM.CallHistory.Count; i++)
     {
         if (MyGSM.CallHistory[i].Duration > maxDuration)
         {
             maxDuration = (int)MyGSM.CallHistory[i].Duration;
             maxIndex = i;
         }
     }
     MyGSM.RemoveCall(maxIndex); //removes the call with the maximum duration and prints
     MyGSM.PrintCallHistory();
     Console.WriteLine("The total price for the calls is: {0} BGN", MyGSM.CalcTotalPriceCallHistory(0.37m));
     Console.WriteLine();
     MyGSM.DeleteHistory(); //clears all calls from the history and prints again
     MyGSM.PrintCallHistory();
 }
示例#24
0
        public static void CallHistoryTest()
        {
            //Create an instance of the GSM class.
            GSM myGsm = GSM.IPhone4S;

            //Add few calls.
            Call someCall = new Call(DateTime.Now, 120, "+359888888888");

            myGsm.AddCall(someCall);
            myGsm.AddCall(someCall);
            myGsm.DeleteCall(someCall);
            myGsm.AddCall(someCall);
            myGsm.AddCall(new Call(new DateTime(2013, 2, 10, 21, 14, 29), 1000, "0885088508"));
            myGsm.AddCall(new Call(new DateTime(2013, 1, 20, 11, 11, 11), 1000, "0885088508"));
            myGsm.AddCall(new Call(DateTime.Now, 119, "+359887121314"));

            //Display the information about the calls.
            Console.WriteLine("All calls:");
            myGsm.PrintAllCalls();

            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            PrintCallPrice(myGsm);

            //Remove the longest call from the historyand calculate the total price again.
            myGsm.RemoveLongestDurationCall();
            Console.WriteLine("\nAfter remove of longest duration call...");
            PrintCallPrice(myGsm);

            //Finally clear the call history and print it.
            myGsm.ClearCallHistory();
            Console.WriteLine("\nAfter clear...");
            myGsm.PrintAllCalls();
            PrintCallPrice(myGsm);
        }
示例#25
0
        private static void GSMCallHistoryTest()
        {
            GSM testGsm = new GSM("Privileg", "MyFriend");

            testGsm.AddCall(DateTime.Now, "+359895258796", 48);
            testGsm.AddCall(DateTime.Now, "+359872456789", 899);
            testGsm.AddCall(DateTime.Now, "+359973679023", 68);
            testGsm.AddCall(DateTime.Now, "+359111222333", 25);
            testGsm.AddCall(DateTime.Now, "+359444555666", 348);

            testGsm.ShowCallHistory();

            Console.WriteLine("Total call price: " + testGsm.TotalCallPrice());

            testGsm.DeleteCall(1);
            Console.WriteLine("Removed the longest call!");

            Console.WriteLine("Total call price: " + testGsm.TotalCallPrice());

            testGsm.ClearCallHistory();
            Console.WriteLine("Cleared call history!");
            testGsm.ShowCallHistory();
        }
示例#26
0
        private static void GSMCallHistoryTest()
        {
            GSM testGsm = new GSM("Nokia", "TelerikCorp");

            testGsm.AddCall("0888888881", 20);
            testGsm.AddCall("0888888882", 60);
            testGsm.AddCall("0888888883", 10);
            testGsm.AddCall("0888888884", 30);
            testGsm.AddCall("+359888888885", 250);

            testGsm.ShowCallHistory();

            Console.WriteLine("Total call price: " + testGsm.TotalCallPrice());

            testGsm.DeleteCall(5);
            Console.WriteLine("Removed Longest call!");

            Console.WriteLine("Total call price: " + testGsm.TotalCallPrice());

            testGsm.ClearCallHistory();
            Console.WriteLine("Cleared call history!");
            testGsm.ShowCallHistory();
        }
示例#27
0
        public static void Main()
        {
            var gsms = new List <GSM>
            {
                new GSM("Galaxy 6", "Samsung", 800.00m, new Battery(BatteryType.LiIon, "model", 500, 100), new Display(5.3)),
                new GSM("6", "IPhone", 1200.00m, new Battery(BatteryType.LiIon, "model", 800, 400), new Display()),
                new GSM("Model", "LG", 400.00m, new Battery(BatteryType.NiCd, "model", 300, 100), new Display(4.5)),
                new GSM("Lumia 930", "Nokia", 500.00m, new Battery(BatteryType.NiMH, "model 3", 400, 200), new Display()),
                new GSM("Neshto si", "Sony", 450.00m, new Battery(BatteryType.NiCd, "model", 343, 140), new Display(4.8)),
                new GSM("Galaxy 4", "Samsung", 550.00m, new Battery(BatteryType.LiIon, "model", 400, 150), new Display())
            };

            foreach (var gsm in gsms)
            {
                Console.WriteLine(gsm);
            }

            Console.WriteLine(GSM.iPhone4s);

            var testCallsGsm = new GSM();

            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(234), "+359888787878"));
            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(434), "+35988865161"));
            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(2234), "+359887846163"));
            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(624), "+359885525056"));
            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(12352), "+359884651625"));

            Console.WriteLine("Before removing the longest call from call history the price is - {0:F2}", testCallsGsm.CalculatePrice(0.37));

            var longestcall = testCallsGsm.CallHistory.OrderByDescending(x => x.Length).FirstOrDefault();

            testCallsGsm.CallHistory.Remove(longestcall);
            Console.WriteLine("After removing the longest call from call history the price is - {0:F2}", testCallsGsm.CalculatePrice(0.37));
            testCallsGsm.ClearHistory();
            Console.WriteLine("After removing all the calls from call history the price is - {0:F2}", testCallsGsm.CalculatePrice(0.37));
        }
示例#28
0
        public static void Main()
        {
            try
            {
                Display display = new Display(4, 16000000);
                Battery battery = new Battery(620, 8, Battery.BatteryModel.NiMH);
                GSM phone = new GSM("One", "HTC", 850, "Person", battery, display);

                GSMTest test = new GSMTest();
                Console.WriteLine("=============");
                test.GSMTesting();
                Console.WriteLine("=============");

                DateTime time = new DateTime();
                time = DateTime.Now;

                Calls[] call = new Calls[5];

                //making some phone calls
                for (int i = 0; i < 5; i++)
                {
                    time = time.AddDays(i);
                    string phoneNumber = "0888999999";
                    int duration = i + 100;
                    call[i] = new Calls(time, phoneNumber, duration);
                    phone.AddCall(call[i]);
                }

                Console.WriteLine();
                decimal pricePerMinute = 0.37m;

                //display call information
                phone.CallHistory();
                Console.WriteLine("=============");
                phone.TotalPriceOfCalls(pricePerMinute);
                Console.WriteLine("=============");
                phone.FindLongestCall();
                phone.TotalPriceOfCalls(pricePerMinute);
                Console.WriteLine("=============");
                phone.ClearCallHistory();
                phone.CallHistory();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public static GSM GenerateCallHistory(GSM phone)
        {
            phone.AddCall(new Call(new DateTime(2015, 3, 10, 10, 21, 00), "+359888888888", 4));
            phone.AddCall(new Call(new DateTime(2015, 3, 10, 10, 25, 00), "+359888888888", 19));
            phone.AddCall(new Call(new DateTime(2015, 3, 10, 10, 45, 00), "+359133713371", 48));

            phone.AddCall(new Call(new DateTime(2015, 3, 11, 22, 35, 00), "+359555555555", 7));
            phone.AddCall(new Call(new DateTime(2015, 3, 11, 22, 48, 00), "+359666666666", 24));
            phone.AddCall(new Call(new DateTime(2015, 3, 11, 23, 15, 00), "+359888888888", 49));

            return phone;
        }
示例#30
0
        public static GSM GenerateCallHistory(GSM phone)
        {
            phone.AddCall(new Call(new DateTime(2015, 3, 10, 10, 21, 00), "+359888888888", 4));
            phone.AddCall(new Call(new DateTime(2015, 3, 10, 10, 25, 00), "+359888888888", 19));
            phone.AddCall(new Call(new DateTime(2015, 3, 10, 10, 45, 00), "+359133713371", 48));

            phone.AddCall(new Call(new DateTime(2015, 3, 11, 22, 35, 00), "+359555555555", 7));
            phone.AddCall(new Call(new DateTime(2015, 3, 11, 22, 48, 00), "+359666666666", 24));
            phone.AddCall(new Call(new DateTime(2015, 3, 11, 23, 15, 00), "+359888888888", 49));

            return(phone);
        }
示例#31
0
        public static void CreateCallHistory()
        {
            GSM testgsm = new GSM();

            Call callOne   = new Call(new DateTime(2015, 02, 03), new DateTime(2015, 02, 03, 14, 05, 25), "private number", 23);
            Call callTwo   = new Call(new DateTime(2015, 02, 03), new DateTime(2015, 02, 03, 17, 14, 38), "private number", 701);
            Call callThree = new Call(new DateTime(2015, 02, 04), new DateTime(2015, 02, 03, 10, 02, 45), "private number", 411);

            //Add few calls
            Console.WriteLine("Added few calls");
            testgsm.CallHistory.Add(callOne);
            testgsm.CallHistory.Add(callTwo);
            testgsm.CallHistory.Add(callThree);



            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Initial number of calls: {0}", testgsm.CallHistory.Count);
            Console.WriteLine("Price of the calls: " + testgsm.CalculateCallPrice());
            Console.WriteLine("Longest call: {0}", testgsm.FindLongestCall().Duration);

            Console.WriteLine("\nAdd a new call");
            testgsm.AddCall(new Call(new DateTime(2015, 02, 04), new DateTime(2015, 02, 03, 10, 33, 45), "private number", 806));
            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Number of calls: {0}", testgsm.CallHistory.Count);
            Console.WriteLine("Price of the calls: " + testgsm.CalculateCallPrice());
            Console.WriteLine("Longest call: {0}", testgsm.FindLongestCall().Duration);

            //Delete longest call
            testgsm.DeleteCall(testgsm.CallHistory.IndexOf(testgsm.FindLongestCall()));
            Console.WriteLine("\nDelete longest call");
            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Number of calls: {0}", testgsm.CallHistory.Count);
            Console.WriteLine("Price of the calls: " + testgsm.CalculateCallPrice());
            Console.WriteLine("Longest call: {0}", testgsm.FindLongestCall().Duration);

            Console.WriteLine("\nDelete all call history");
            testgsm.DeleteAllHistory();
            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Number of calls: {0}", testgsm.CallHistory.Count);


            Console.WriteLine(testgsm.CallHistory.Count);
        }
        public static void CallsHistoryTest()
        {
            foreach (Call call in calls)
            {
                test.AddCall(call);
            }

            Console.WriteLine("\n\nPresenting information about three calls:");
            Console.WriteLine(new string('=', 41));

            foreach (Call call in test.CallHistory)
            {
                Console.WriteLine(call);
            }

            Console.WriteLine("\nTotal price of the calls: {0}", test.CallsTotalPrice(0.37m));

            Call longestCall = test.CallHistory[0];

            for (int i = 1; i < test.CallHistory.Count; i++)
            {
                if (test.CallHistory[i].Duration > longestCall.Duration)
                {
                    longestCall = test.CallHistory[i];
                }
            }

            test.CallHistory.Remove(longestCall);

            Console.WriteLine("\nRemoving the longest call:");
            Console.WriteLine(longestCall);
            Console.WriteLine("\nTotal price of the calls (after the removing): {0}", test.CallsTotalPrice(0.37m));

            test.ClearCallHistory();

            Console.WriteLine("\nClearing the call history...");
            Console.WriteLine("\nTotal price of the calls: {0}", test.CallsTotalPrice(0.37m));
            Console.WriteLine(new string('=', 34));
        }