Exemplo n.º 1
0
        static void CallHistoryTest()
        {
            Console.WriteLine("===================Call History Test===================");

            GSM lg = new GSM("G4", "LG", 1000, "Petkan", new Battery("G2", 50, 5, BatteryType.Li_Ion), new Display(5, 60000));

            lg.AddCall(new Calls("28/04/2016", "14:46", "0886723987", 144));
            lg.AddCall(new Calls("15/03/2015", "13:42", "0885885937", 751));
            lg.AddCall(new Calls("01/06/2016", "18:13", "0883946721", 451));

            for (int i = 0; i < lg.CallHistory.Count; i++)
            {
                Console.WriteLine(lg.CallHistory[i]);
            }
            Console.WriteLine("Calls Price: {0:f2}", lg.GetTotalCallPrice(0.37m));

            Calls longestCall = lg.CallHistory[0];

            foreach (var call in lg.CallHistory)
            {
                if (call.Duration > longestCall.Duration)
                {
                    longestCall = call;
                }
            }
            lg.DeleteCall(longestCall);
            Console.WriteLine("Calls Price without longest: {0:f2}", lg.GetTotalCallPrice(0.37m));
            lg.ClearCallHistory();
            Console.WriteLine("Call history cleared!");
        }
Exemplo n.º 2
0
        public static void TestGSMCallHistory()
        {
            GSM gsm = new GSM("GalaxyS7", "Samsung", 1100, "Someone", new Battery("3000 mAh", 44, 22, BatteryType.LiIon), new Display(5.1, 16000000));
            //List<Call> listOfCalls = new List<Call>();
            //listOfCalls.Add(new Call((new DateTime(2016, 12, 18)), DateTime.Parse("20:35:12"), "0123456", 210));
            //listOfCalls.Add(new Call((new DateTime(2015, 05, 01)), DateTime.Parse("13:12:54"), "6543210", 1431));
            //listOfCalls.Add(new Call((new DateTime(2014, 01, 31)), DateTime.Parse("23:29:01"), "1234567", 353));

            Call firstCall  = new Call((new DateTime(2016, 12, 18)), DateTime.Parse("20:35:12"), "0123456", 210);
            Call secondCall = new Call((new DateTime(2015, 05, 01)), DateTime.Parse("13:12:54"), "6543210", 1431);
            Call thirdCall  = new Call((new DateTime(2014, 01, 31)), DateTime.Parse("23:29:01"), "1234567", 353);

            gsm.AddCall(firstCall);
            gsm.AddCall(secondCall);
            gsm.AddCall(thirdCall);
            //initial call history
            Console.WriteLine("Call history:");
            Console.WriteLine(gsm.CallHistory);
            Console.WriteLine();
            Console.WriteLine("Total price of the calls:");
            Console.WriteLine(gsm.PriceOfCalls(0.37m));
            gsm.DeleteCall(gsm.FindLongestCall());
            //after deleting the longest call
            Console.WriteLine(Startup.dashLine);
            Console.WriteLine("Call history without longest call:");
            Console.WriteLine(gsm.CallHistory);
            Console.WriteLine();
            Console.WriteLine("Total price of the calls:");
            Console.WriteLine(gsm.PriceOfCalls(0.37m));
            //after clearing the history
            Console.WriteLine(Startup.dashLine);
            gsm.DeleteHistory();
            Console.WriteLine("Call history without any calls:");
            Console.WriteLine(gsm.CallHistory);
            Console.WriteLine();
            Console.WriteLine("Total price of the calls:");
            Console.WriteLine(gsm.PriceOfCalls(0.37m));
        }