Esempio n. 1
0
File: GSMTest.cs Progetto: GAlex7/TA
        static void Main()
        {
            //GSM[] arr = new GSM[3];
            //arr[0] = new GSM("Google Nexus 3", "Samsung", 400, "-", new Battery("Removable", BatteryType.LiIon, 270, 8), new Display(4.65f, 16000000));
            //arr[1] = new GSM("Galaxy S5", "Samsung", 800, "-", new Battery("Removable", BatteryType.LiIon, 390, 21), new Display(5.1f, 16000000));
            //arr[2] = new GSM("Ascend P7", "Huawei", 650, "-", new Battery("Non-removable", BatteryType.LiPol, 422, 14), new Display(5f, 16000000));

            //for (int i = 0; i < arr.Length; i++)
            //{
            //    Console.WriteLine(arr[i]);
            //    Console.WriteLine();
            //}

            Console.WriteLine(GSM.IPhone4S);
            Console.WriteLine();

            var myPhone = new GSM("Google Nexus 3", "Samsung", 400, "-", new Battery("Removable", BatteryType.LiIon, 270, 8), new Display(4.65f, 16000000));

            myPhone.AddCall(new Call(new DateTime(2015, 3, 5, 10, 15, 7), "+359880123456", 10));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 6, 8, 13, 7), "+359888888888", 65));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 7, 13, 17, 7), "+359880123456", 100));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 8, 22, 37, 7), "0880123456", 50));

            PrintTotal(myPhone);

            myPhone.DeleteCall(2); // longest call is with index 2

            PrintTotal(myPhone);

            myPhone.ClearCalls();

            PrintTotal(myPhone);
        }
Esempio n. 2
0
        static void Main()
        {
            //GSM[] arr = new GSM[3];
            //arr[0] = new GSM("Google Nexus 3", "Samsung", 400, "-", new Battery("Removable", BatteryType.LiIon, 270, 8), new Display(4.65f, 16000000));
            //arr[1] = new GSM("Galaxy S5", "Samsung", 800, "-", new Battery("Removable", BatteryType.LiIon, 390, 21), new Display(5.1f, 16000000));
            //arr[2] = new GSM("Ascend P7", "Huawei", 650, "-", new Battery("Non-removable", BatteryType.LiPol, 422, 14), new Display(5f, 16000000));

            //for (int i = 0; i < arr.Length; i++)
            //{
            //    Console.WriteLine(arr[i]);
            //    Console.WriteLine();
            //}

            Console.WriteLine(GSM.IPhone4S);
            Console.WriteLine();

            var myPhone = new GSM("Google Nexus 3", "Samsung", 400, "-", new Battery("Removable", BatteryType.LiIon, 270, 8), new Display(4.65f, 16000000));

            myPhone.AddCall(new Call(new DateTime(2015, 3, 5, 10, 15, 7), "+359880123456", 10));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 6, 8, 13, 7), "+359888888888", 65));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 7, 13, 17, 7), "+359880123456", 100));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 8, 22, 37, 7), "0880123456", 50));


            PrintTotal(myPhone);

            myPhone.DeleteCall(2); // longest call is with index 2

            PrintTotal(myPhone);

            myPhone.ClearCalls();

            PrintTotal(myPhone);
        }
        public void CallHistoryTest()
        {
            GSM myPhone = new GSM("Lumia", "Nokia");
            //public Call(string date, string time, string dialed, long duration)
            List <Call> someCalls = new List <Call> {
                new Call("02.02.2015", "15:45", "0896232333", 56),
                new Call("03.18.2015", "11:45", "0852454555", 13),
                new Call("01.02.2015", "00:05", "0899656598", 118),
                new Call("03.15.2015", "18:32", "0896232333", 65)
            };

            foreach (Call a in someCalls)
            {
                myPhone.AddCall(a);
            }
            myPhone.DisplayCalls();
            double price = 0.37;

            Console.WriteLine("With price of 0.37 per minute, the total cost of the calls:" + myPhone.CalcPrice(price / 60));
            Console.WriteLine("Removing the longest call ...");
            myPhone.DeleteCall(someCalls[2]);
            Console.WriteLine("With price of 0.37 per minute, the total cost of the calls:" + myPhone.CalcPrice(price / 60));
            myPhone.ClearHistory();
            Console.WriteLine("History Cleared");
            Console.WriteLine("Current History:");
            myPhone.DisplayCalls();
        }
        static void Main(string[] args)
        {
            GSM gsm = new GSM("testModel", "testManufacturer");

            gsm.AddCall(new Call("11.02.2013", "18:32", "00000000", 432));
            gsm.AddCall(new Call("11.02.2013", "19:02", "00000001", 23));
            gsm.AddCall(new Call("12.02.2013", "11:28", "00000010", 5243));

            foreach (Call call in gsm.CallHistory)
            {
                Console.WriteLine("Call date: " + call.Date);
                Console.WriteLine("Call time: " + call.Time);
                Console.WriteLine("Call phone number: " + call.PhoneNumber);
                Console.WriteLine("Call duration: " + call.Duration);
                Console.Write("\n");
            }

            Console.WriteLine("Total price: " + gsm.TotalPrice(0.37m));

            gsm.DeleteCall(2);

            Console.WriteLine("Total price without the longest call: " + gsm.TotalPrice(0.37m));
            Console.Write("\n");

            foreach (Call call in gsm.CallHistory)
            {
                Console.WriteLine("Call date: " + call.Date);
                Console.WriteLine("Call time: " + call.Time);
                Console.WriteLine("Call phone number: " + call.PhoneNumber);
                Console.WriteLine("Call duration: " + call.Duration);
                Console.Write("\n");
            }

            gsm.ClearCallHistory();

            foreach (Call call in gsm.CallHistory)
            {
                Console.WriteLine("Call date: " + call.Date);
                Console.WriteLine("Call time: " + call.Time);
                Console.WriteLine("Call phone number: " + call.PhoneNumber);
                Console.WriteLine("Call duration: " + call.Duration);
                Console.Write("\n");
            }
        }
Esempio n. 5
0
        static void CallHistoryTest()
        {
            decimal pricePerMinute = 0.37m;

            Console.WriteLine("Let we test th call history! Ready? ...................\n");

            GSM GFlex = new GSM("G-Flex", "LG", (decimal)399.99, "Pavkata",
                                new Battery("G5", 90, 8, BatteryType.LithiumPolymer),
                                new Display((decimal)5.2, 16000000));

            GFlex.AddCall(new Calls("01/01/2001", "00:01", "0883654675", 567));
            GFlex.AddCall(new Calls("20/07/2013", "22:40", "0894223760", 120));
            GFlex.AddCall(new Calls("29/02/2016", "05:10", "0899132465", 221));
            GFlex.AddCall(new Calls("16/06/2016", "11:59", "0895386583", 21));
            GFlex.AddCall(new Calls("31/06/2016", "06:09", "0877975201", 243));

            for (int i = 0; i < GFlex.History.Count; i++)
            {
                Console.WriteLine(GFlex.History[i]);
            }

            Console.WriteLine("Calls Price: {0:F2}", GFlex.totalPrice(pricePerMinute));

            Calls longest = GFlex.History[0];

            foreach (var call in GFlex.History)
            {
                if (call.CallDuration > longest.CallDuration)
                {
                    longest = call;
                }
            }
            GFlex.DeleteCall(longest);
            Console.WriteLine("Calls Price without longest: {0:F2}", GFlex.totalPrice(pricePerMinute));

            GFlex.ClearCallHistory();
            Console.WriteLine("Call history cleared!");
        }
Esempio n. 6
0
        public static void CallHistoryTest()
        {
            Console.WriteLine("*************Call History Test*************");
            //Create an instance of the GSM class.
            GSM samsung = new GSM("S5", "Samsung", 1000, "Ivancho", new Battery("G2", 50, 5, BatteryType.LiIon), new Display(5, 500000));

            //Add few calls.
            samsung.AddCall(new Call("30/05/2016", "14:06", "0884089756", 104));
            samsung.AddCall(new Call("23/01/2015", "12:42", "0883208975", 311));
            samsung.AddCall(new Call("31/04/2016", "11:12", "0884589752", 151));

            //Display the information about the calls.
            for (int i = 0; i < samsung.CallHistory.Count; i++)
            {
                Console.WriteLine(samsung.CallHistory[i]);
            }

            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            Console.WriteLine("Calls Price: {0:f2}", samsung.GetTotalCallPrice(0.37m));

            //Remove the longest call from the history and calculate the total price again.
            Call longestCall = samsung.CallHistory[0];

            foreach (var call in samsung.CallHistory)
            {
                if (call.Duration > longestCall.Duration)
                {
                    longestCall = call;
                }
            }
            samsung.DeleteCall(longestCall);
            Console.WriteLine("Calls Price without longest: {0:f2}", samsung.GetTotalCallPrice(0.37m));

            //Finally clear the call history and print it.
            samsung.ClearCallHistory();
            Console.WriteLine("Call history cleared!");
        }
Esempio n. 7
0
        public static void Test()
        {
            var phone = new GSM("MyPhone", "Apple");

            phone.AddCall(new Call(DateTime.Now, "Pesho", 45));
            phone.AddCall(new Call(DateTime.Now, "Ivan", 18));
            phone.AddCall(new Call(DateTime.Now, "Gosho", 80));

            // phone.PrintCalls();
            Console.WriteLine(phone.CallsToString());

            Console.WriteLine("Total Price: {0:f2}", phone.CallsPrice(0.37));

            var longestCall = phone
                              .CheckCalls()
                              .OrderByDescending(x => x.Duration)
                              .FirstOrDefault();

            if (phone.RemoveCall(longestCall))
            {
                Console.WriteLine("Longest call was removed");
            }
            else
            {
                // if cant remove longest call then probably list is empty
                Console.WriteLine("Are you sure there are calls in phone call history?");
            }


            Console.WriteLine("Total Price: {0:f2}", phone.CallsPrice(0.37));

            phone.ClearHistory();

            //phone.PrintCalls();
            Console.WriteLine(phone.CallsToString());
        }
        public void CallHistoryTest()
        {
            GSM peshoGSM = new GSM("Nokia", "Nokia");
            Call firstCall = new Call(DateTime.Now, "0888080808", 3000);
            Call secondCall = new Call(DateTime.Now,"0888080808", 3500);
            Call thirdCall = new Call(DateTime.Now, "0888080808", 2000);
            peshoGSM.AddCall(firstCall);
            peshoGSM.AddCall(secondCall);
            peshoGSM.AddCall(thirdCall);

            Console.WriteLine(peshoGSM.CallHistoryInfo());

            decimal price = 0.37M;

            Console.WriteLine("Total price: {0:F2}",peshoGSM.CalculateTotalPriceOfCalls(price));

            int longest=0;
            Call longestCall = new Call(DateTime.Now,"0888888888",0);

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

            peshoGSM.DeleteCall(longestCall);

            Console.WriteLine("Total price after longest call has been removed: {0:F2}", peshoGSM.CalculateTotalPriceOfCalls(price));

            peshoGSM.ClearCalls();

            peshoGSM.CallHistoryInfo();
        }
 public void CallHistoryTest()
 {
     GSM myPhone = new GSM("Lumia", "Nokia");
             //public Call(string date, string time, string dialed, long duration)
     List<Call> someCalls =new List<Call> {
     new Call("02.02.2015", "15:45", "0896232333", 56),
     new Call("03.18.2015", "11:45", "0852454555", 13),
     new Call("01.02.2015", "00:05", "0899656598", 118),
     new Call("03.15.2015", "18:32", "0896232333", 65)};
     foreach (Call a in someCalls)
     { myPhone.AddCall(a); }
     myPhone.DisplayCalls();
     double price = 0.37;
     Console.WriteLine("With price of 0.37 per minute, the total cost of the calls:" + myPhone.CalcPrice(price/60));
     Console.WriteLine("Removing the longest call ...");
     myPhone.DeleteCall(someCalls[2]);
     Console.WriteLine("With price of 0.37 per minute, the total cost of the calls:" + myPhone.CalcPrice(price / 60));
     myPhone.ClearHistory();
     Console.WriteLine("History Cleared");
     Console.WriteLine("Current History:");
     myPhone.DisplayCalls();
 }
Esempio n. 10
0
        public static void Test()
        {
            GSM phone = new GSM("Samsung", "Galaxy S3");

            //Add calls
            GSMCallHistoryTest.Calls = new List<Calls>
            {
                new Calls(new DateTime(2015, 03, 17, 10, 32, 23), "0887591529", 35),
                new Calls(new DateTime(2015, 03, 17, 11, 32, 23), "0887595629", 56),
                new Calls(new DateTime(2015, 03, 17, 13, 32, 23), "0887576529", 39)
            };
            foreach (Calls call in GSMCallHistoryTest.Calls)
            {
                phone.AddCall(call);
            }

            GSMCallHistoryTest.PrintInfoCalls(GSM.CallHistory);

            Console.WriteLine("Total price is {0:F2}", GSM.CalculateTotalPrice(0.37));
            RemoveLongestCall(phone, GSM.CallHistory);
            Console.WriteLine("Total price without the longest call is {0:F2}", GSM.CalculateTotalPrice(0.37));
            phone.ClearCallHistory();
        }
Esempio n. 11
0
        public static void Test()
        {
            GSM phone = new GSM("Samsung", "Galaxy S3");

            //Add calls
            GSMCallHistoryTest.Calls = new List <Calls>
            {
                new Calls(new DateTime(2015, 03, 17, 10, 32, 23), "0887591529", 35),
                new Calls(new DateTime(2015, 03, 17, 11, 32, 23), "0887595629", 56),
                new Calls(new DateTime(2015, 03, 17, 13, 32, 23), "0887576529", 39)
            };
            foreach (Calls call in GSMCallHistoryTest.Calls)
            {
                phone.AddCall(call);
            }

            GSMCallHistoryTest.PrintInfoCalls(GSM.CallHistory);

            Console.WriteLine("Total price is {0:F2}", GSM.CalculateTotalPrice(0.37));
            RemoveLongestCall(phone, GSM.CallHistory);
            Console.WriteLine("Total price without the longest call is {0:F2}", GSM.CalculateTotalPrice(0.37));
            phone.ClearCallHistory();
        }
Esempio n. 12
0
        public static void CallHistoryTest()
        {
            // Create an instance of the GSM class.
            GSM myFirstIPhone = new GSM(
                "IPhone5",
                "Apple",
                55.99,
                "Gosho Bacov",
                new Display(9, 500000000),
                new Battery(BatteryType.LithiumSulfur, "Li-lon", 10, 4.5),
                new Call(DateTime.Now, "0899 513 321", 60));


            // Add few calls.
            myFirstIPhone.AddCall(new Call(DateTime.UtcNow, "0888 888 888", 162));
            myFirstIPhone.AddCall(new Call(DateTime.Today, "0999 235 123", 42));
            myFirstIPhone.AddCall(new Call(DateTime.Now, "0999 999 999", 70));


            // Display the information about the calls.
            var historyCalls = myFirstIPhone.CallHistory;

            foreach (var call in historyCalls)
            {
                Console.WriteLine(call.ToString());
                Console.WriteLine();
            }


            // Assuming that the price per minute is 0.37 calculate
            // and print the total price of the calls in the history.
            double price;

            price = myFirstIPhone.CallPrice(myFirstIPhone.CallHistory);
            Console.WriteLine($"{price:F2}");
            Console.WriteLine();


            // Remove the longest call from the history and calculate the total price again.
            var  historyCallsList = myFirstIPhone.CallHistory;
            int  longestCall      = historyCallsList[0].DurationInSeconds;
            Call callForRemuve    = myFirstIPhone.CallHistory[0];

            foreach (var call in historyCallsList)
            {
                if (longestCall < call.DurationInSeconds)
                {
                    callForRemuve = call;
                }
            }
            myFirstIPhone.DelCall(callForRemuve);

            // print again
            historyCalls = myFirstIPhone.CallHistory;
            foreach (var call in historyCalls)
            {
                Console.WriteLine(call.ToString());
                Console.WriteLine();
            }

            double newPrice;

            newPrice = myFirstIPhone.CallPrice(myFirstIPhone.CallHistory);
            Console.WriteLine($"{newPrice:F2}");
            Console.WriteLine();


            // Finally clear the call history and print it.
            myFirstIPhone.ClearHistory();

            if (myFirstIPhone.CallHistory.Count == 0)
            {
                Console.WriteLine("Call history is EMPTY !!!");
            }
            else
            {
                historyCalls = myFirstIPhone.CallHistory;
                foreach (var call in historyCalls)
                {
                    Console.WriteLine(call.ToString());
                    Console.WriteLine();
                }
            }
        }