Exemplo n.º 1
0
        public static void Test()
        {
            GSM gsmNote =
                new GSM("Note 7", "Samsung", 1000M, "Viktor",
                        new Battery("Samsung", 100, 40, BatteryType.LiIon),
                        new Display(1024, 1024));

            Call firstCall = new Call();

            firstCall.DateTime          = new DateTime(2017, 7, 18);
            firstCall.DialedPhoneNumber = "08888888";
            firstCall.DurationInSeconds = 60;

            Call secondCall = new Call();

            secondCall.DateTime          = new DateTime(2016, 7, 18);
            secondCall.DialedPhoneNumber = "088888884";
            secondCall.DurationInSeconds = 65;

            gsmNote.AddCall(firstCall);
            gsmNote.AddCall(secondCall);

            foreach (Call call in gsmNote.CallHistory)
            {
                Console.WriteLine(call);
            }
        }
        static void GSMCallHistoryTest()
        {
            GSM myGSM = new GSM("Samsung", "Galaxy S2", 500, "Jimmy Hendrix", new Battery("HJ/T43456-2012", 190, 12, BatteryType.LiIon), new Display(4.7, 16));

            myGSM.AddCall("22.12.2014", "11:55:32", "0888123456", 132);
            myGSM.AddCall("23.12.2014", "12:56:33", "0888654321", 160);
            myGSM.AddCall("24.12.2014", "13:57:34", "0888456123", 258);
            myGSM.AddCall("25.12.2014", "14:58:35", "0888654123", 400);
            myGSM.AddCall("26.12.2014", "15:59:36", "0888321654", 17);

            Console.WriteLine(myGSM.ShowCallHistory());

            Console.WriteLine("Total call price: {0:F2}", myGSM.CallPrice(0.37M));

            int longestCall = myGSM.CallHistory[0].Duration;
            int longestCallIndex = 0;
            for (int i = 0; i < myGSM.CallHistory.Count; i++)
            {
                int temp = myGSM.CallHistory[i].Duration;
                if (longestCall < temp)
                {
                    longestCall = temp;
                    longestCallIndex = i;
                }
            }

            myGSM.RemoveCall(myGSM.CallHistory[longestCallIndex]);
            // Console.WriteLine("longest call is {0}s and it costs {1:F2}", longestCall, longestCall * 0.37 / 60);
            Console.WriteLine("Total call price after deleting the longest call: {0:F2}", myGSM.CallPrice(0.37M));

            myGSM.ClearCallHistory();
            Console.WriteLine(myGSM.ShowCallHistory());
        }
        static void GSMCallHistoryTest()
        {
            GSM myGSM = new GSM("Samsung", "Galaxy S2", 500, "Jimmy Hendrix", new Battery("HJ/T43456-2012", 190, 12, BatteryType.LiIon), new Display(4.7, 16));

            myGSM.AddCall("22.12.2014", "11:55:32", "0888123456", 132);
            myGSM.AddCall("23.12.2014", "12:56:33", "0888654321", 160);
            myGSM.AddCall("24.12.2014", "13:57:34", "0888456123", 258);
            myGSM.AddCall("25.12.2014", "14:58:35", "0888654123", 400);
            myGSM.AddCall("26.12.2014", "15:59:36", "0888321654", 17);

            Console.WriteLine(myGSM.ShowCallHistory());

            Console.WriteLine("Total call price: {0:F2}", myGSM.CallPrice(0.37M));

            int longestCall      = myGSM.CallHistory[0].Duration;
            int longestCallIndex = 0;

            for (int i = 0; i < myGSM.CallHistory.Count; i++)
            {
                int temp = myGSM.CallHistory[i].Duration;
                if (longestCall < temp)
                {
                    longestCall      = temp;
                    longestCallIndex = i;
                }
            }

            myGSM.RemoveCall(myGSM.CallHistory[longestCallIndex]);
            // Console.WriteLine("longest call is {0}s and it costs {1:F2}", longestCall, longestCall * 0.37 / 60);
            Console.WriteLine("Total call price after deleting the longest call: {0:F2}", myGSM.CallPrice(0.37M));

            myGSM.ClearCallHistory();
            Console.WriteLine(myGSM.ShowCallHistory());
        }
Exemplo n.º 4
0
 public void CallHistoryTest()
 {
     var peshoPhone = new GSM("HD2", "HTC", 100000M, "Pesho",
     new Battery("PeshoBattery", 31231, 31312, BatteryType.LiIon),
     new Display(10f, 20000000));
     peshoPhone.AddCall("739172937193", 105);
     peshoPhone.AddCall("0854646466464", 2000);
     peshoPhone.AddCall("0864646464", 15);
     peshoPhone.AddCall("0888556464", 62);
     peshoPhone.ShowHistory();
     decimal peshoBill = peshoPhone.CalculateTotalPrice(0.37M);
     Console.WriteLine("{0} has to pay {1:F2}{2}", peshoPhone.Owner, peshoBill,
     RegionInfo.CurrentRegion.CurrencySymbol);
     peshoPhone.DeleteCall("0854646466464");
     peshoPhone.ShowHistory();
     peshoBill = peshoPhone.CalculateTotalPrice(0.37M);
     Console.WriteLine("{0} has to pay {1:F2}{2}", peshoPhone.Owner, peshoBill,
     RegionInfo.CurrentRegion.CurrencySymbol);
     peshoPhone.ClearCallHistory();
     peshoPhone.ShowHistory();
 }
Exemplo n.º 5
0
        public static void Test()
        {
            GSM gsmNote =
                new GSM("Note 7", "Samsung", 1000M, "Viktor",
                        new Battery("Samsung", 100, 40, BatteryType.LiIon),
                        new Display(1024, 1024));

            gsmNote.AddCall(new Call());


            GSM gsmHtc =
                new GSM("OneTouch", "HTC", 9000M, "Ivan",
                        new Battery("HTC", 105, 43, BatteryType.NiCd),
                        new Display(1024, 1024));

            GSM[] gsms = new GSM[] { gsmNote, gsmHtc, GSM.IPhone4S };
            foreach (GSM gsm in gsms)
            {
                Console.WriteLine(gsm);
            }
        }