Exemple #1
0
        static void Main()
        {
            Console.WriteLine(GSM.iphone4s + "\n"); //Iphone

            //Test phone
            GSM mobile = new GSM("Galaxy-s-3-neo", "Samsung", 200, "Mitko", "HP-100", 150, 120, BatteryType.NiCd, 230, 5605);

            Console.WriteLine(mobile);

            var testGMSs = GSMTest.gsmTests;

            GSMTest.PrintTestGSM(testGMSs);

            var callHistory = CallHistoryTest.callHistory;

            GSM.DisplayCallHistory(callHistory);                   //Printing calls

            CallHistoryTest.PrintTestCallPrice(callHistory, 0.37); //Printing price

            CallHistoryTest.RemoveLongestCall(callHistory, 0.37);  //After removing longest call

            Console.WriteLine("\nClearing all call history...");
            callHistory.Clear();
            GSM.DisplayCallHistory(callHistory);
            Console.WriteLine("\nAll history cleared");
        }
Exemple #2
0
 public static void Test()
 {
     Console.WriteLine("GSM Test: ");
     string[] gsmModels = { "C2-01", "H2-05", "V6", "Galaxy S3", "IPhone 5", "Xperia 7", "1616" };
     string[] Manufacturer = { "Nokia", "Samsung", "HTC", "Sony", "Apple", "Motorola" };
     string[] batteryModels = { "Nokia battery", "Samsung battery", "HTC battery", "Sony battery", "IPhone 5 battery", "Motorola battery" };
     string[] owners = { "Kir4o", "Pesho", "Gosho", "Nataliq", "Dessy", "Iva", "Mimi", "Vesi" };
     BatteryType[] batteryType = { BatteryType.LiIon, BatteryType.NiCd, BatteryType.NiMH };
     Random randomGenerator = new Random();
     int arrayLength = randomGenerator.Next(1, 6);
     GSM[] GSMs = new GSM[arrayLength];
     for (int index = 0; index < arrayLength; index++)
     {
         GSMs[index] = new GSM(gsmModels[randomGenerator.Next(0, 7)], Manufacturer[randomGenerator.Next(0, 6)]);
         GSMs[index].Owner = owners[randomGenerator.Next(0, 8)];
         GSMs[index].Price = (decimal)(randomGenerator.NextDouble() * randomGenerator.Next(50, 1000));
         GSMs[index].Battery = new Battery(batteryModels[randomGenerator.Next(0, 6)]);
         GSMs[index].Battery.Type = batteryType[randomGenerator.Next(0, 3)];
         GSMs[index].Battery.IdleHours = randomGenerator.Next(3, 64);
         GSMs[index].Battery.TalkHours = randomGenerator.Next(1, 10);
         GSMs[index].Display = new Display();
         GSMs[index].Display.Size = randomGenerator.Next(3, 10);
         GSMs[index].Display.Colors = randomGenerator.Next(256, 2931348);
         Console.WriteLine(GSMs[index].ToString());
         Console.WriteLine();
     }
     Console.WriteLine("IPhone 4s information: ");
     GSM iphone4s = GSM.IPhone4S();
     Console.WriteLine(iphone4s.ToString());
 }
 public static void Test()
 {
     Console.WriteLine();
     Console.WriteLine("GSM Call History Test:");
     GSM myGSM = new GSM("C2-01", "Nokia");
     DateTime date = new DateTime();
     TimeSpan time = new TimeSpan();
     date = DateTime.Now.Date;
     time = DateTime.Now.TimeOfDay;
     myGSM.AddCall(date, time, 98325, 33);
     myGSM.AddCall(date.AddDays(2), time, 111111, 67);
     myGSM.AddCall(date.AddDays(7), time, 324624, 50);
     int maxIndex = 0;
     for (int index = 0; index < myGSM.CallHistory.Count; index++)
     {
         if (myGSM.CallHistory[maxIndex].Duration < myGSM.CallHistory[index].Duration)
         {
             maxIndex = index;
         }
         Console.WriteLine(myGSM.CallHistory[index].ToString());
     }
     Console.WriteLine();
     Console.Write("The total price for all calls is: {0}$", myGSM.CalculatePrice(0.37m));
     Console.WriteLine();
     Console.WriteLine("The longest call duration is {0}",myGSM.CallHistory[maxIndex].ToString());
     myGSM.DeleteCall(maxIndex);
     Console.WriteLine("The new price without the longest call is: {0}$",myGSM.CalculatePrice(0.37m));
     myGSM.ClearCallHistory();
 }
Exemple #4
0
        public static void RemoveLongestCall(List <Call> callHistory, double price)
        {
            var orderedCalls = callHistory.OrderBy(x => x.Duration).ToList();

            orderedCalls.RemoveAt(orderedCalls.Count - 1);

            var testPrice = GSM.CallsPrice(orderedCalls, price);

            Console.WriteLine("After removing the longest call: {0:F2}", testPrice);
        }
Exemple #5
0
        static void Main()
        {
            try
            {
                //initializing new gsm
                GSM MyGSM = new GSM("Monte", "Samsung", 10, "Pesho",
                    "DINO", 10, 6, BatteryType.LiIon, 7, 256000);

                //setting static field value
                GSM.IPhone = "This is some information for IPhone4S";

                //Perform calls
                MyGSM.PerformCall(new DateTime(2013, 2, 3), DateTime.Now, "0898654793", 300);
                MyGSM.PerformCall(new DateTime(2013, 2, 7), DateTime.Now, "0898654703", 600);
                MyGSM.PerformCall(new DateTime(2013, 2, 13), DateTime.Now, "0898254793", 200);
                MyGSM.PerformCall(new DateTime(2013, 2, 15), DateTime.Now, "0898647793", 100);
                MyGSM.PerformCall(new DateTime(2013, 2, 16), DateTime.Now, "0898251793", 1300);

                //display history
                Console.WriteLine(MyGSM.DisplayCallHistory());

                //calculate and display calls price
                Console.WriteLine("Calls price is {0:C}\n", MyGSM.CalculateCallsPrice((decimal)0.37));

                //delete history record
                MyGSM.DeleteCall("0898251793");

                //calculate and display calls price again
                Console.WriteLine("Calls price is {0:C}\n", MyGSM.CalculateCallsPrice((decimal)0.37));

                //display history again
                Console.WriteLine(MyGSM.DisplayCallHistory());

                //clear history
                MyGSM.ClearHistory();

                //display history again
                Console.WriteLine(MyGSM.DisplayCallHistory());

                //displaing info
                Console.WriteLine(MyGSM);

                //getting static field value
                Console.WriteLine(GSM.IPhone);
            }
            catch(ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }
        }
 static void Main()
 {
     GSM nokia = new GSM("E-65", "Nokia");
     nokia.AddCall("0889186005", 237);
     nokia.AddCall("0889182205", 114);
     nokia.AddCall("0889346005", 87);
     nokia.AddCall("0889346108", 111);
     nokia.DisplayCallInformation();
     Console.WriteLine("Current bill for this number {0} Leva.\n", nokia.GetCallsPrice(0.37m));
     nokia.RemoveCall();
     nokia.DisplayCallInformation();
     nokia.ClearCallHistory();
     nokia.DisplayCallInformation();
 }
Exemple #7
0
        static void Main()
        {
            GSM nokia = new GSM("E-65", "Nokia");

            nokia.AddCall("0889186005", 237);
            nokia.AddCall("0889182205", 114);
            nokia.AddCall("0889346005", 87);
            nokia.AddCall("0889346108", 111);
            nokia.DisplayCallInformation();
            Console.WriteLine("Current bill for this number {0} Leva.\n", nokia.GetCallsPrice(0.37m));
            nokia.RemoveCall();
            nokia.DisplayCallInformation();
            nokia.ClearCallHistory();
            nokia.DisplayCallInformation();
        }
Exemple #8
0
        public static void AddingCalls()
        {
            GSM samsung = new GSM("Galaxy Note 3", "Samsung", 200, "Bai Veselin",
                                  new Battery("Removable", 2, 6, BatteryType.LiIon),
                                  new Display(5.7, 25600000));

            samsung.Adding(new Call("10.06.2016", "16:48", "0886014325", 0.06m));
            samsung.Adding(new Call("11.06.2016", "17:48", "0886014325", 0.56m));
            samsung.Adding(new Call("13.06.2016", "19:18", "0886014425", 0.36m));
            samsung.Adding(new Call("14.06.2016", "06:45", "0886014325", 0.26m));
            samsung.Adding(new Call("15.06.2016", "16:43", "0886018625", 0.12m));

            foreach (var call in samsung.CallHistory)
            {
                Console.WriteLine(call.ToString());
            }
            Console.WriteLine("Call Price before removing a call: {0:F5}", samsung.CallPrice());
            List <Call> calls       = samsung.CallHistory;
            decimal     currentCall = 0;
            int         index       = 0;

            for (int i = 0; i < calls.Count; i++)
            {
                if (currentCall < calls[i].Duration)
                {
                    currentCall = calls[i].Duration;
                    index       = i;
                }
            }
            samsung.Deleting(index);
            Console.WriteLine("Call price after removing a call: {0:F5}", samsung.CallPrice());
            samsung.Clear();
            foreach (var call in samsung.CallHistory)
            {
                Console.WriteLine(call.ToString());
            }
        }
Exemple #9
0
 public void TestMethod8()
 {
     GSM MyGSM = new GSM("Monte", "Samsung", 10, "Pesho", "DINO", 10, 6, BatteryType.LiIon, 7, -256000);
 }
Exemple #10
0
        static void Main(string[] args)
        {
            // testing GSM - creating array of GSM objects
            Console.WriteLine("------------------------TESTING GSM CLASS -------------------");
            GSM[] array = new GSM[] {
                new GSM("7250", "Nokia", 250, "Atanas Ivanov"),
                new GSM("GT-I9100", "Samsung", 680),
                new GSM("Xperia Z", "Sony", 800, "Momchil Georgiev"),
                new GSM("Galaxy S4", "Samsung", 1000, "Some Person", new Battery(BatteryType.NiMh), new Display(15, 16000000))
            };

            // Printing the information of the mobile devices in the array
            for (int i = 0; i < array.Length; i++)
            {
                Console.WriteLine(array[i].ToString());
            }

            // Printing the information about the static iPhone
            Console.WriteLine("..:: Static Member iPhone info ::..");
            Console.WriteLine("Manufacturer: " + GSM.iPhone.Manufacturer);
            Console.WriteLine("Model: " + GSM.iPhone.Model);
            Console.WriteLine("Price: " + GSM.iPhone.Price);
            Console.WriteLine();


            // testing call history
            Console.WriteLine("------------------------TESTING CALL CLASS -------------------");

            GSM myPhone = new GSM("Galaxy S2", "Samsung", 980, "Kolio Kolev", new Battery(BatteryType.LiIon, "IOP456", 500, 250), new Display(640, 16000000));

            myPhone.AddCallToHistory("123456789", 890);
            myPhone.AddCallToHistory("348732478", 345);
            myPhone.AddCallToHistory("*88", 123);

            // Print initial call history
            Console.WriteLine("..:: Call History ::..");
            foreach (var call in myPhone.CallHistory)
            {
                Console.WriteLine("{0} {1} {2}", call.DateAndTime, call.PhoneNumber, call.Duration);
            }

            // Print total costs of calls in history
            Console.WriteLine("..:: Total Costs ::..");
            Console.WriteLine(myPhone.CalculateTotalPriceOfCalls(0.37));

            // Total costs after removing the call with the longes duration
            Console.WriteLine("..:: New Total Costs ::..");
            myPhone.RemoveCallsFromHistoryViaDuration(890);
            Console.WriteLine(myPhone.CalculateTotalPriceOfCalls(0.37));

            // Print the new call history, after the call is removed
            Console.WriteLine("..:: New Call History ::..");
            foreach (var call in myPhone.CallHistory)
            {
                Console.WriteLine("{0} {1} {2}", call.DateAndTime, call.PhoneNumber, call.Duration);
            }

            // Clearing the call history and printing it(suppose nothing is expected to be printed)
            myPhone.ClearCallHistory();
            foreach (var call in myPhone.CallHistory)
            {
                Console.WriteLine("{0} {1} {2}", call.DateAndTime, call.PhoneNumber, call.Duration);
            }
        }
Exemple #11
0
        public static void PrintTestCallPrice(List <Call> callHistory, double price)
        {
            var testPrice = GSM.CallsPrice(callHistory, price);

            Console.WriteLine("\nTotal price of test calls: {0:F2}", testPrice);
        }
        static void Main(string[] args)
        {
            // testing GSM - creating array of GSM objects
            Console.WriteLine("------------------------TESTING GSM CLASS -------------------");
            GSM[] array = new GSM[] {
                                        new GSM("7250", "Nokia", 250, "Atanas Ivanov"),
                                        new GSM("GT-I9100", "Samsung", 680),
                                        new GSM("Xperia Z", "Sony", 800, "Momchil Georgiev"),
                                        new GSM("Galaxy S4", "Samsung", 1000, "Some Person", new Battery(BatteryType.NiMh),new Display(15,16000000))
            };

            // Printing the information of the mobile devices in the array
            for (int i = 0; i < array.Length; i++)
            {
                Console.WriteLine(array[i].ToString());
            }

            // Printing the information about the static iPhone
            Console.WriteLine("..:: Static Member iPhone info ::..");
            Console.WriteLine("Manufacturer: "+GSM.iPhone.Manufacturer);
            Console.WriteLine("Model: "+GSM.iPhone.Model);
            Console.WriteLine("Price: " +GSM.iPhone.Price);
            Console.WriteLine();

            // testing call history
            Console.WriteLine("------------------------TESTING CALL CLASS -------------------");

            GSM myPhone = new GSM("Galaxy S2", "Samsung", 980, "Kolio Kolev", new Battery(BatteryType.LiIon, "IOP456", 500, 250), new Display(640, 16000000));

            myPhone.AddCallToHistory("123456789", 890);
            myPhone.AddCallToHistory("348732478", 345);
            myPhone.AddCallToHistory("*88", 123);

            // Print initial call history
            Console.WriteLine("..:: Call History ::..");
            foreach (var call in myPhone.CallHistory)
            {
                Console.WriteLine("{0} {1} {2}", call.DateAndTime, call.PhoneNumber, call.Duration);
            }

            // Print total costs of calls in history
            Console.WriteLine("..:: Total Costs ::..");
            Console.WriteLine(myPhone.CalculateTotalPriceOfCalls(0.37));

            // Total costs after removing the call with the longes duration
            Console.WriteLine("..:: New Total Costs ::..");
            myPhone.RemoveCallsFromHistoryViaDuration(890);
            Console.WriteLine(myPhone.CalculateTotalPriceOfCalls(0.37));

            // Print the new call history, after the call is removed
            Console.WriteLine("..:: New Call History ::..");
            foreach (var call in myPhone.CallHistory)
            {
                Console.WriteLine("{0} {1} {2}", call.DateAndTime, call.PhoneNumber, call.Duration);
            }

            // Clearing the call history and printing it(suppose nothing is expected to be printed)
            myPhone.ClearCallHistory();
            foreach (var call in myPhone.CallHistory)
            {
                Console.WriteLine("{0} {1} {2}", call.DateAndTime, call.PhoneNumber, call.Duration);
            }
        }