コード例 #1
0
        public static void Test()
        {
            GSM htc = new GSM("One S", "HTC");

            htc.AddCall(new Call(new DateTime(2015, 02, 01, 14, 52, 02), "+359886645879", new TimeSpan(0, 5, 20)));
            htc.AddCall(new Call(new DateTime(2015, 02, 03, 18, 20, 02), "+359886645879", new TimeSpan(0, 45, 2)));
            //htc.AddCall(new Call(new DateTime(2015, 02, 03, 18, 10, 02), "+359886645800", new TimeSpan(0, 45, 2)));
            htc.AddCall(new Call(new DateTime(2015, 02, 20, 10, 10, 55), "+359884865849", new TimeSpan(0, 3, 10)));
            foreach (var call in htc.CallHistory)
            {
                Console.WriteLine(call);
            }
            Console.WriteLine("Total price: {0}", htc.CalcTotalPrice(0.37M).ToString("C", new System.Globalization.CultureInfo("en-US")));
            var         longestCallDuration = htc.CallHistory.Max(c => c.Duration);
            List <Call> longestCalls        = htc.CallHistory.Where(c => c.Duration == longestCallDuration).ToList();

            foreach (var call in longestCalls)
            {
                htc.DeleteCall(call);
            }
            foreach (var call in htc.CallHistory)
            {
                Console.WriteLine(call);
            }
            Console.WriteLine("Total price: {0}", htc.CalcTotalPrice(0.37M).ToString("C", new System.Globalization.CultureInfo("en-US")));
            htc.ClearHistory();
            foreach (var call in htc.CallHistory)
            {
                Console.WriteLine(call);
            }
        }
コード例 #2
0
        public static GSM GenerateCallHistory()
        {
            GSM gsm = new GSM("Galaxy S3", "Samsung");
            gsm.AddCall(new Call(new DateTime(2015, 03, 09, 22, 03, 05), "+359 879 654321", 30));
            gsm.AddCall(new Call(new DateTime(2015, 03, 10, 15, 13, 17), "+359 899 123456", 12));
            gsm.AddCall(new Call(new DateTime(2015, 03, 10, 18, 03, 43), "+359 879 654321", 49));
            gsm.AddCall(new Call(new DateTime(2015, 03, 15, 11, 35, 25), "+359 856 754236", 154));
            gsm.AddCall(new Call(new DateTime(2015, 03, 16, 17, 03, 14), "+359 897 651241", 37));

            return gsm;
        }
コード例 #3
0
        public static GSM GenerateCallHistory()
        {
            GSM gsm = new GSM("Galaxy S3", "Samsung");

            gsm.AddCall(new Call(new DateTime(2015, 03, 09, 22, 03, 05), "+359 879 654321", 30));
            gsm.AddCall(new Call(new DateTime(2015, 03, 10, 15, 13, 17), "+359 899 123456", 12));
            gsm.AddCall(new Call(new DateTime(2015, 03, 10, 18, 03, 43), "+359 879 654321", 49));
            gsm.AddCall(new Call(new DateTime(2015, 03, 15, 11, 35, 25), "+359 856 754236", 154));
            gsm.AddCall(new Call(new DateTime(2015, 03, 16, 17, 03, 14), "+359 897 651241", 37));

            return(gsm);
        }
コード例 #4
0
ファイル: GSMTest.cs プロジェクト: vstoyanov88/TelerikAcademy
        static void Main()
        {
            GSM phone1 = new GSM();
            phone1.Price = 10;
            phone1.Owner = "az";

            GSM phone2 = new GSM();
            phone2.Price = 12;
            phone2.Manifacturer = "made in china";
            phone2.Model = "samsung 2";

            GSM phone3 = new GSM();
            phone3.Model = "nokia q";
            phone3.Owner = "pesho";
            phone3.Manifacturer = " made in china";

            GSM[] phones = new GSM[] { phone1, phone2, phone3 };
            foreach (GSM phone in phones)
            {
                phone.DisplayGsm();
                Console.WriteLine();
            }

            GSM.Iphone.DisplayGsm();

            Battery battery = new Battery(BatteryType.NiCd);
            Console.WriteLine(battery.Type);

            Call firstCall = new Call(DateTime.Now, 0987654321, 324);
            Call secondCall = new Call();
            secondCall.Number = 0999999;
            secondCall.Seconds = 433;
            GSM calls = new GSM("samsung", "china");

            //--------------
            //test call history
            //---------------
            calls.AddCall(DateTime.Now, 0987654321, 234);
            calls.AddCall(DateTime.Now, 1234567890, 342);
            calls.DeleteCall(DateTime.Now, 1234567890, 342);
            foreach (var call in calls.Callhistory)
            {
                Console.WriteLine("{0} {1} {2}", call.DateTime, call.Number, call.Seconds);
            }

            Console.WriteLine( calls.CallPrice(0.34) );
            calls.RemoveAllCalls();
            foreach (var call in calls.Callhistory)
            {
                Console.WriteLine("{0} {1} {2}", call.DateTime, call.Number, call.Seconds);
            }
        }
コード例 #5
0
ファイル: GSMTest.cs プロジェクト: mpenchev86/Telerik-Academy
 public void TestGSMs()
 {
     GSM[] testGSMs = new GSM[3];
     testGSMs[0] = new GSM("Sprint", "Samsung");
     testGSMs[1] = new GSM("One (M8)", "HTC", new Battery("", 496, 20, BatteryType.LiPo));
     testGSMs[2] = new GSM(
         "Lumia 638", "Nokia", 192.00, "Pesho Goshov", new Battery("", BatteryType.LiIon),
         new Display(4.5));
     foreach (GSM gsm in testGSMs)
     {
         gsm.ToString();
     }
     GSM.IPhone4S.ToString();
 }
コード例 #6
0
ファイル: GSMTest.cs プロジェクト: mpenchev86/Telerik-Academy
 public void TestGSMs()
 {
     GSM[] testGSMs = new GSM[3];
     testGSMs[0] = new GSM("Sprint", "Samsung");
     testGSMs[1] = new GSM("One (M8)", "HTC", new Battery("", 496, 20, BatteryType.LiPo));
     testGSMs[2] = new GSM(
         "Lumia 638", "Nokia", 192.00, "Pesho Goshov", new Battery("", BatteryType.LiIon),
         new Display(4.5));
     foreach (GSM gsm in testGSMs)
     {
         gsm.ToString();
     }
     GSM.IPhone4S.ToString();
 }
コード例 #7
0
        public GSMCallHistoryTest()
        {
            //creating gsm
            GSM gsm = new GSM("Samsung", "A35");

            //creating some calls
            Console.WriteLine("Adding call with duration {0} minutes and {1} seconds", 20, 30);
            Call call1 = new Call(new DateTime(2012, 1, 22), new TimeSpan(0, 22, 30), "+35932423224");

            Console.WriteLine();
            Console.WriteLine("Adding call with duration {0} minutes and {1} seconds", 15, 11);
            Call call2 = new Call(new DateTime(2012, 1, 23), new TimeSpan(0, 15, 11), "+35932413324");

            Console.WriteLine();
            Console.WriteLine("Adding call with duration {0} minutes and {1} seconds", 7, 30);
            Call call3 = new Call(new DateTime(2012, 1, 24), new TimeSpan(0, 7, 30), "+3593243424");

            Console.WriteLine();

            Console.WriteLine("Adding calls to call history");
            Console.WriteLine();

            //adding calls to call history
            gsm.CallHistory.Add(call1);
            gsm.CallHistory.Add(call2);
            gsm.CallHistory.Add(call3);

            //calculating total price
            Console.WriteLine("Total call price:");

            Console.WriteLine(gsm.TotalCallsPrice(0.37M));
            Console.WriteLine();
            //finding longest call
            Call longestCall = (from e in gsm.CallHistory
                                orderby e.Duration descending
                                select e).First();

            //removing longest call

            gsm.CallHistory.Remove(longestCall);

            //calculating price again
            Console.WriteLine("Total call price after longest call has been removed:");

            Console.WriteLine(gsm.TotalCallsPrice(0.37M));
            //clearing history
            Console.WriteLine("History cleared!");
            Console.WriteLine();
            gsm.ClearCallsHistory();
        }
コード例 #8
0
        public GSMCallHistoryTest()
        {
            //creating gsm
            GSM gsm = new GSM("Samsung", "A35");

            //creating some calls
            Console.WriteLine("Adding call with duration {0} minutes and {1} seconds", 20, 30);
            Call call1 = new Call(new DateTime(2012, 1, 22), new TimeSpan(0, 22, 30), "+35932423224");
            Console.WriteLine();
            Console.WriteLine("Adding call with duration {0} minutes and {1} seconds", 15, 11);
            Call call2 = new Call(new DateTime(2012, 1, 23), new TimeSpan(0, 15, 11), "+35932413324");
            Console.WriteLine();
            Console.WriteLine("Adding call with duration {0} minutes and {1} seconds", 7, 30);
            Call call3 = new Call(new DateTime(2012, 1, 24), new TimeSpan(0, 7, 30), "+3593243424");
            Console.WriteLine();

            Console.WriteLine("Adding calls to call history");
            Console.WriteLine();

            //adding calls to call history
            gsm.CallHistory.Add(call1);
            gsm.CallHistory.Add(call2);
            gsm.CallHistory.Add(call3);

            //calculating total price
            Console.WriteLine("Total call price:");

            Console.WriteLine(gsm.TotalCallsPrice(0.37M));
            Console.WriteLine();
            //finding longest call
            Call longestCall = (from e in gsm.CallHistory
                                orderby e.Duration descending
                                select e).First();

            //removing longest call

            gsm.CallHistory.Remove(longestCall);

            //calculating price again
            Console.WriteLine("Total call price after longest call has been removed:");

            Console.WriteLine(gsm.TotalCallsPrice(0.37M));
            //clearing history
            Console.WriteLine("History cleared!");
            Console.WriteLine();
            gsm.ClearCallsHistory();
        }
コード例 #9
0
        public static void Main()
        {
            // GSM Test
            List <GSM> phones = GSMTest.GeneratePhones();

            // Print information on the console for all instances of phones
            PrintSeparator("GSM Test");
            foreach (var phone in phones)
            {
                Console.WriteLine(phone.ToString());
            }

            // Call History test
            PrintSeparator("Call history test");

            GSM gsm = CallHistoryTest.GenerateCallHistory();

            // Print on the console the call history
            PrintCallHistory(gsm);

            Console.WriteLine("Removing longest call from call history...");
            Console.WriteLine();

            // Remove longest call from call history
            Call longestCall = gsm.CallHistory[0];

            foreach (var call in gsm.CallHistory)
            {
                if (call.Duration > longestCall.Duration)
                {
                    longestCall = call;
                }
            }

            gsm.RemoveCall(longestCall);

            // Print on the console the call history
            PrintCallHistory(gsm);

            // Clear call history
            gsm.DeleteCallHistory();

            // Print after deleting call history
            PrintCallHistory(gsm);
        }
コード例 #10
0
ファイル: Main.cs プロジェクト: DareDev1l/TelerikAcademy
        public static void PrintCallHistory(GSM gsm)
        {
            foreach (var call in gsm.CallHistory)
            {
                Console.WriteLine(call.ToString());
            }

            // Print total call price
            double price = gsm.CallPrice(0.37);
            if (price > 0)
            {
                Console.WriteLine("Total price of the calls: {0:C}", price);
            }
            else
            {
                Console.WriteLine("No call history");
            }
            Console.WriteLine();
        }
コード例 #11
0
        public static void PrintCallHistory(GSM gsm)
        {
            foreach (var call in gsm.CallHistory)
            {
                Console.WriteLine(call.ToString());
            }

            // Print total call price
            double price = gsm.CallPrice(0.37);

            if (price > 0)
            {
                Console.WriteLine("Total price of the calls: {0:C}", price);
            }
            else
            {
                Console.WriteLine("No call history");
            }
            Console.WriteLine();
        }
コード例 #12
0
            public GSMCallHistoryTest()
            {
                GSM gsm = new GSM("Galaxy S2", "Samsung");

                Call call1 = new Call(new DateTime(2012, 1, 22), new TimeSpan(0, 22, 30), "+35932423224");
                Call call2 = new Call(new DateTime(2012, 1, 23), new TimeSpan(0, 15, 11), "+35932413324");
                Call call3 = new Call(new DateTime(2012, 1, 24), new TimeSpan(0, 7, 30), "+3593243424");

                List <Call> callHistory = new List <Call>();

                callHistory.Add(call1);
                callHistory.Add(call2);
                callHistory.Add(call3);

                gsm.CallHistory = callHistory;

                Console.WriteLine(gsm.TotalCallsPrice(0.37M));

                //TODO:
                //Remove the longest call from the history and calculate the total price again.

                gsm.ClearCallsHistory();
            }
コード例 #13
0
            public GSMCallHistoryTest()
            {
                GSM gsm = new GSM("Galaxy S2", "Samsung");

                Call call1 = new Call(new DateTime(2012, 1, 22), new TimeSpan(0, 22, 30), "+35932423224");
                Call call2 = new Call(new DateTime(2012, 1, 23), new TimeSpan(0, 15, 11), "+35932413324");
                Call call3 = new Call(new DateTime(2012, 1, 24), new TimeSpan(0, 7, 30), "+3593243424");

                List<Call> callHistory = new List<Call>();
                callHistory.Add(call1);
                callHistory.Add(call2);
                callHistory.Add(call3);

                gsm.CallHistory = callHistory;

                Console.WriteLine(gsm.TotalCallsPrice(0.37M));

                //TODO:
                //Remove the longest call from the history and calculate the total price again.

                gsm.ClearCallsHistory();
            }
コード例 #14
0
 public void TestHistory()
 {
     GSM newPhone = new GSM("One (M8)", "HTC", new Battery("", 496, 20, BatteryType.LiPo));
 }
コード例 #15
0
 public void TestHistory()
 {
     GSM newPhone = new GSM("One (M8)", "HTC", new Battery("", 496, 20, BatteryType.LiPo));
 }