Beispiel #1
0
        public static void GSMCallHistoryTest()
        {
            GSM oboroten = new GSM("Nokia W8", "Nokia Corp.", 220, "Ivanchoy", new Battery("Zbot", 8, 3, BattertType.Li_Lon), new Display(4.2, 555000));

            oboroten.AddCall(new DateTime(2015, 3, 15), "0893345323", 415);
            oboroten.AddCall(new DateTime(2015, 2, 10), "0881500162", 845);
            oboroten.AddCall(new DateTime(2015, 2, 10), "0875916442", 45);
            oboroten.AddCall(new DateTime(2015, 2, 11), "0891500156", 165);
            oboroten.AddCall(new DateTime(2015, 2, 6), "0891547400", 264);
            oboroten.AddCall(new DateTime(2015, 2, 5), "0881622317", 942);
            oboroten.AddCall(new DateTime(2015, 2, 9), "0879455161", 315);
            oboroten.AddCall(new DateTime(2015, 3, 15), "0893345323", 548); // call again to first number
            //Show calls
            oboroten.ShowCallListHystorY();
            // Total calls

            Console.WriteLine("Total price is: ${0:F2}", oboroten.TotalPrice());
            //Remove the longest call
            uint max   = 0;
            int  index = -1;

            foreach (var item in oboroten.CallsHistory)
            {
                if (item.Duration > max)
                {
                    max   = item.Duration;
                    index = oboroten.CallsHistory.IndexOf(item);
                }
            }
            oboroten.DeleteCallAtPosition(index);
            // Caling again this metod
            oboroten.ShowCallListHystorY();
            Console.WriteLine("After delete max duration call. Total price is: ${0:F2}", oboroten.TotalPrice());

            // Clear the call list
            Console.WriteLine("Delete all calls...");
            oboroten.ClearHystor();
            oboroten.ShowCallListHystorY();
        }