Ejemplo n.º 1
0
        public static GSM[] CreateArray()
        {
            GSM[] array = new GSM[5];
            Battery[] batteries = new Battery[5];
            Display[] displays = new Display[5];

            //Batteries
            batteries[0] = new Battery("Unknown", 0, 0, BatteryType.LiIon);
            batteries[1] = new Battery("GalaxyS Battery", 200, 30, BatteryType.LiIon);
            batteries[2] = new Battery("Lumia Battery", 200, 30, BatteryType.LiIon);
            batteries[3] = new Battery("Dell", 200, 30, BatteryType.LiIon);
            batteries[4] = new Battery("GalaxyS", 30, 3, BatteryType.LiIon);

            //Displays
            displays[0] = new Display(4.0, 65000);
            displays[1] = new Display(4.0, 65000);
            displays[2] = new Display(4.0, 65000);
            displays[3] = new Display(4.0, 65000);
            displays[4] = new Display(4.0, 65000);

            //GSMs
            array[0] = new GSM("Unknown", "Unknown", 300, null, batteries[0], displays[0]);
            array[1] = new GSM("Galaxy S", "Samsung", 500, "Peter", batteries[1], displays[1]);
            array[2] = new GSM("Lumia 920", "Nokia", 500, "Ivan", batteries[2], displays[2]);
            array[3] = new GSM("Dell GSM", "Dell", 300, null, batteries[3], displays[3]);
            array[4] = new GSM("Galaxy S2", "Samsung", 300, "Joro", batteries[4], displays[4]);

            return array;
        }
Ejemplo n.º 2
0
 public static void DisplayCalls(GSM gsm)
 {
     foreach (var item in gsm.CallHistory)
     {
         Console.WriteLine(item.ToString());
     }
 }
Ejemplo n.º 3
0
        public static void CallHistoryTest()
        {
            //Create an instance of the GSM class.
            GSM myGsm = GSM.IPhone4S;

            //Add few calls.
            Call someCall = new Call(DateTime.Now, 120, "+359888888888");

            myGsm.AddCall(someCall);
            myGsm.AddCall(someCall);
            myGsm.DeleteCall(someCall);
            myGsm.AddCall(someCall);
            myGsm.AddCall(new Call(new DateTime(2013, 2, 10, 21, 14, 29), 1000, "0885088508"));
            myGsm.AddCall(new Call(new DateTime(2013, 1, 20, 11, 11, 11), 1000, "0885088508"));
            myGsm.AddCall(new Call(DateTime.Now, 119, "+359887121314"));

            //Display the information about the calls.
            Console.WriteLine("All calls:");
            myGsm.PrintAllCalls();

            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            PrintCallPrice(myGsm);

            //Remove the longest call from the historyand calculate the total price again.
            myGsm.RemoveLongestDurationCall();
            Console.WriteLine("\nAfter remove of longest duration call...");
            PrintCallPrice(myGsm);

            //Finally clear the call history and print it.
            myGsm.ClearCallHistory();
            Console.WriteLine("\nAfter clear...");
            myGsm.PrintAllCalls();
            PrintCallPrice(myGsm);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            //var model = Console.ReadLine();

            //var manufacturer = Console.ReadLine();

            //var price = decimal.Parse(Console.ReadLine());

            //var owner = Console.ReadLine();

            //GSM myGSM = new GSM(model, manufacturer, price, owner);

            //myGSM.MyBattery.Model = Console.ReadLine();

            //BatteryType type;
            //string inputType = Console.ReadLine();
            //var parsedType = Enum.TryParse(inputType, out type);

            //myGSM.MyBattery.Type = type;

            //Console.WriteLine(myGSM);
            GSMTest currTest = new GSMTest();

            Console.WriteLine(currTest.ToString());

            var model   = Console.ReadLine();
            var manu    = Console.ReadLine();
            GSM currGSM = new GSM(model, manu);

            currGSM.AddCall()
        }
Ejemplo n.º 5
0
        static void Main()
        {
            GSM mobile = new GSM("Samsung", "Galaxy S5360", 330, "Evgeni Velikov");

            mobile.AddCall(new Call(300));
            mobile.AddCall(new Call(4000));
            mobile.AddCall(new Call(120));

            Console.WriteLine("Total Price: {0:C}", mobile.CalculateTotalPrice());

            mobile.RemoveCall(new Call(4000));

            Console.WriteLine("Total Price After Remove: {0:C}", mobile.CalculateTotalPrice());

            mobile.RemoveAllCall();

            Console.WriteLine("Remove Total Price: {0:C}", mobile.CalculateTotalPrice());

            Console.WriteLine();

            mobile.battery.HoursIdle = 340;
            mobile.battery.HoursTalk = 12;
            mobile.battery.Model     = BatteryType.Li_Ion;
            mobile.display.Size      = "320x480";
            mobile.display.Colors    = 65895;

            Console.WriteLine(mobile);
        }
 static void Main()
 {
     GSM MyGSM = new GSM("Galaxy S4", "Samsung",750.00m,"Slavi");
     // create an instance of the GSM class to test the call history functionality
     MyGSM.AddCall(new Call(new DateTime(2013, 09, 24, 10, 33, 00), "0887551432", 133));
     MyGSM.AddCall(new Call(new DateTime(2013, 09, 24, 11, 54, 10), "0886113432", 63));
     MyGSM.AddCall(new Call(new DateTime(2013, 09, 24, 23, 11, 23), "0886113432", 234));
     MyGSM.AddCall(new Call(new DateTime(2013, 09, 25, 07, 30, 03), "+359887551432", 73));
     MyGSM.AddCall(new Call(new DateTime(2013, 09, 25, 10, 04, 27), "+359897143223", 105));
     MyGSM.AddCall(new Call(new DateTime(2013, 09, 26, 15, 10, 55), "0878751030", 15));
     //add few calls and prints call history
     MyGSM.PrintCallHistory();
     Console.WriteLine();
     Console.WriteLine("The total price for the calls is: {0} BGN", MyGSM.CalcTotalPriceCallHistory(0.37m));
     //finds the longest call index
     int maxDuration = -1;
     int maxIndex = -1;
     for (int i = 0; i < MyGSM.CallHistory.Count; i++)
     {
         if (MyGSM.CallHistory[i].Duration > maxDuration)
         {
             maxDuration = (int)MyGSM.CallHistory[i].Duration;
             maxIndex = i;
         }
     }
     MyGSM.RemoveCall(maxIndex); //removes the call with the maximum duration and prints
     MyGSM.PrintCallHistory();
     Console.WriteLine("The total price for the calls is: {0} BGN", MyGSM.CalcTotalPriceCallHistory(0.37m));
     Console.WriteLine();
     MyGSM.DeleteHistory(); //clears all calls from the history and prints again
     MyGSM.PrintCallHistory();
 }
        public static void GSMCallHistoryTestMethod()
        {
            Console.WriteLine("\n------------------------------------");
            Console.WriteLine("        Call History Test!");
            Console.WriteLine("------------------------------------\n");

            GSM phone = new GSM("Galaxy S 3", "Samsung");

            phone.AddCall(new Call(DateTime.Parse("6/12/2009 07:23:00 AM"), "0888123456") { Duration = 31 });
            phone.AddCall(new Call(DateTime.Parse("10/11/2010 10:44:00 AM"), "0888678910") { Duration = 360 });
            phone.AddCall(new Call(DateTime.Parse("7/05/2012 06:56:00 PM"), "0888111213") { Duration = 600 });

            PrintCalls(phone);

            //Get longest call.
            var maxCall =
                (from call in phone.CallHistory
                 orderby call.Duration descending
                 select call).First();

            //Delete longest call.
            phone.DeleteCall(phone.CallHistory.IndexOf(maxCall));

            PrintCalls(phone);

            //Clear all calls.
            phone.ClearHistory();

            PrintCalls(phone);
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {


            Console.WriteLine("{0,10}TASK FROM 1-4",string.Empty);
            Console.WriteLine();
            GSM newGSMOne = new GSM("Lumia 900", "Nokia", 900, "Vasil");//instance with full contrsuctor arguments
            newGSMOne.PrintGSMInfo();
            newGSMOne.BaterryInfo.PrintBaterryInfo();
            newGSMOne.DisplayInfo.PrintDisplayInfo();

            Console.WriteLine();
            Console.WriteLine("{0,10}TASK FROM 5-7", string.Empty);
            GSMTest.TestGSM();

            Console.WriteLine();
            Console.WriteLine("{0,10}TASK FROM 8-12", string.Empty);
            GSMCallHistoryTest.AddCallTest();
            GSMCallHistoryTest.PrintCallHistoty();
            GSMCallHistoryTest.PrintBill();
            Console.WriteLine();
            GSM.RemoveCall();
            Console.Write("Total Amout after we delete longest call is {0}.");
            GSMCallHistoryTest.PrintBill();
            GSM.RemoveAllCalls();
            Console.WriteLine("History after removing all Calls.");
            GSMCallHistoryTest.PrintCallHistoty();  
            
        } 
Ejemplo n.º 9
0
        public static void Main()
        {
            var gsms = new List<GSM>
            {
                new GSM("Galaxy 6", "Samsung", 800.00m, new Battery(BatteryType.LiIon, "model", 500, 100), new Display(5.3)),
                new GSM("6", "IPhone", 1200.00m, new Battery(BatteryType.LiIon, "model", 800, 400), new Display()),
                new GSM("Model", "LG", 400.00m, new Battery(BatteryType.NiCd, "model", 300, 100), new Display(4.5)),
                new GSM("Lumia 930", "Nokia", 500.00m, new Battery(BatteryType.NiMH, "model 3", 400, 200), new Display()),
                new GSM("Neshto si", "Sony", 450.00m, new Battery(BatteryType.NiCd, "model", 343, 140), new Display(4.8)),
                new GSM("Galaxy 4", "Samsung", 550.00m, new Battery(BatteryType.LiIon, "model", 400, 150), new Display())
            };

            foreach (var gsm in gsms)
            {
                Console.WriteLine(gsm);
            }

            Console.WriteLine(GSM.iPhone4s);

            var testCallsGsm = new GSM();
            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(234), "+359888787878"));
            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(434), "+35988865161"));
            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(2234), "+359887846163"));
            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(624), "+359885525056"));
            testCallsGsm.AddCall(new Call(DateTime.Now, DateTime.Now.AddSeconds(12352), "+359884651625"));

            Console.WriteLine("Before removing the longest call from call history the price is - {0:F2}", testCallsGsm.CalculatePrice(0.37));

            var longestcall = testCallsGsm.CallHistory.OrderByDescending(x => x.Length).FirstOrDefault();
            testCallsGsm.CallHistory.Remove(longestcall);
            Console.WriteLine("After removing the longest call from call history the price is - {0:F2}", testCallsGsm.CalculatePrice(0.37));
            testCallsGsm.ClearHistory();
            Console.WriteLine("After removing all the calls from call history the price is - {0:F2}", testCallsGsm.CalculatePrice(0.37));
        }
Ejemplo n.º 10
0
        public static void StartGSMTest()
        {
            //creating GSM objects
            GSM[] gsmArray =
            {
                new GSM("Xperia Z",                   "Sony",     569.99m, "Stefka",  new Battery(BatteryType.NiCd,  30, 700),
                        new Display(4.9m,            16000000)),

                new GSM("Galaxy S8",                  "Samsung",  779.99m, "Dimitar", new Battery(BatteryType.LiIon, 20, 420),
                        new Display(5.8m,            32000000)),

                new GSM("Iphone 7",                   "",        1199.99m, "Atanas",  new Battery(BatteryType.NiMH,  26, 500),
                        new Display(4.7m,            32000000)),

                new GSM("Vibe C",                     "Lenovo",   349.99m, "Tanya",   new Battery(BatteryType.LiPo,  18, 460),
                        new Display(5.2m, 16000000))
            };

            //print info for every mobile phone
            foreach (GSM mobilePhone in gsmArray)
            {
                Console.WriteLine(mobilePhone);
            }

            //print GSM class static field
            Console.WriteLine(GSM.PrintStaticFieldInfo());
        }
        static void Main()
        {
            GSM mobile = new GSM("Samsung", "Galaxy S5360", 330, "Evgeni Velikov");

            mobile.AddCall(new Call(300));
            mobile.AddCall(new Call(4000));
            mobile.AddCall(new Call(120));

            Console.WriteLine("Total Price: {0:C}", mobile.CalculateTotalPrice());

            mobile.RemoveCall(new Call(4000));

            Console.WriteLine("Total Price After Remove: {0:C}", mobile.CalculateTotalPrice());

            mobile.RemoveAllCall();

            Console.WriteLine("Remove Total Price: {0:C}", mobile.CalculateTotalPrice());

            Console.WriteLine();

            mobile.battery.HoursIdle = 340;
            mobile.battery.HoursTalk = 12;
            mobile.battery.Model = BatteryType.Li_Ion;
            mobile.display.Size = "320x480";
            mobile.display.Colors = 65895;

            Console.WriteLine(mobile);
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            GSM[] phones = new GSM[4];

            phones[0] = new GSM("BlackBerry", "BlackBerry", 300, "Gosho",
                new Battery("7V900S", 44.4, 8.3, BatteryType.LiIon), new Display(4, 16000));

            phones[1] = new GSM("Iphone 5", "Apple", 1000, "Misho",
                new Battery("7V901S", 66.3, 10.3, BatteryType.NiCd), new Display(8, 65000));

            phones[2] = new GSM("Xperia Tipo", "Sony", 150, "Pesho",
                new Battery("7V902S", 33.1, 5.3, BatteryType.NiMH), new Display(5, 16000));

            phones[3] = new GSM("Galaxy S 3", "Samsung", 1100, "Ceko",
                new Battery("7V903S", 80.5, 15.5), new Display(9, 65000));

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

            //This is the static property!
            Console.WriteLine("\nStatic property:\n\n{0}", GSM.Iphone4S);

            //Call History Test!
            GSMCallHistoryTest.GSMCallHistoryTestMethod();
        }
 public static void PrintHistory(GSM phone)
 {
     foreach (var call in phone.CallHistory)
     {
         Console.WriteLine(call.ToString());
     }
 }
Ejemplo n.º 14
0
 public static void CreateGSMs()
 {
     for (int i = 0; i < 10; i++)
     {
         GSMs[i] = new GSM("G" + rand.Next(10, 50).ToString(), "Samsung", (decimal)rand.Next(300, 900), "unknown", new Battery(rand.Next(16, 36), rand.Next(4, 16), (EnumBatterytype)rand.Next(1, 3)), new Display(rand.Next(5, 12), 123000000));
     }
 }
Ejemplo n.º 15
0
 public static void PrintHistory(GSM phone)
 {
     foreach (var call in phone.CallHistory)
     {
         Console.WriteLine(call.ToString());
     }
 }
Ejemplo n.º 16
0
        public void GsmCallHistoryTest()
        {
            GSM gsm = new GSM();
            gsm.AddCalls(new Call("12.05.2015", "23:52:31", "+359869256543", 60));
            gsm.AddCalls(new Call("03.06.2015", "13:42:32", "+359849213553", 32));
            gsm.AddCalls(new Call("24.05.2015", "14:52:33", "+359899228563", 60));
            gsm.AddCalls(new Call("15.03.2015", "12:22:34", "+359889237573", 660));
            gsm.AddCalls(new Call("26.07.2015", "10:32:35", "+359989246523", 60));
            gsm.AddCalls(new Call("17.03.2015", "08:12:36", "+359889255529", 32));
            gsm.AddCalls(new Call("08.02.2015", "02:32:37", "+359889264503", 56));
            gsm.AddCalls(new Call("29.08.2015", "23:52:37", "+359889273593", 120));

            int theLongestCall = 0;
            int index = 0;

            if (gsm.HistoryCall.Count != 0)
            {
                for (int i = 0; i < gsm.HistoryCall.Count; i++)
                {
                    Console.WriteLine(gsm.HistoryCall[i]);

                    if (gsm.HistoryCall[i].Duration > theLongestCall)
                    {
                        theLongestCall = gsm.HistoryCall[i].Duration;
                        index = i;
                    }

                    Console.WriteLine(new string('-', 70));
                }
            }
            else
            {
                Console.WriteLine("The call history is empty");
            }

            Console.WriteLine("Total price of the calls in the call history is: {0}", gsm.TotalPriceOfTheCallHistory(0.37M));

            gsm.DeleteCalls(index);
            Console.WriteLine(new string('-', 70));
            Console.WriteLine("After remove the longest call:");
            Console.WriteLine("Total price of the calls in the call history is: {0}", gsm.TotalPriceOfTheCallHistory(0.37M));
            Console.WriteLine(new string('-', 70));

            gsm.ClearCallHistory();

            if (gsm.HistoryCall.Count != 0)
            {
                foreach (var item in gsm.HistoryCall)
                {
                    Console.WriteLine(item);
                }
            }
            else
            {
                Console.WriteLine("The call history is empty");
            }
        }
Ejemplo n.º 17
0
 public static void DisplayGMSInformation(GSM[] array)
 {
     foreach (var item in array)
     {
         Console.WriteLine("Information about GSM {0}:", item.Model);
         Console.WriteLine(item);
         Console.WriteLine();
     }
 }
Ejemplo n.º 18
0
        static void Main()
        {
            GSM cellSamsung    = new GSM("6s", "Samsung", 1199.99, "pcSHop", new Battery(BatteryType.Unknown, "a123asw", 200, 24), new Display(12.4, 5000000));
            GSM cellTelefunken = new GSM("NovaStar", "Telefunken", 399.99, "Technopolis", new Battery(BatteryType.Li_Ion, "a1dd23asw", 100, 14), new Display(12.4, 5000000));
            GSM cellLG         = new GSM("Nexus", "LG");

            PrintCellPhones();
            PrintIphoneDetails();
            CallHistoryTest.TestCallHistory();
        }
Ejemplo n.º 19
0
        public static void PrintGSMsInfo(GSM[] gsms)
        {
            for (int i = 0; i < gsms.Length; i++)
            {
                Console.WriteLine("Sample GSM {0}: {1}", i + 1, gsms[i]);
                Console.WriteLine();
            }

            Console.WriteLine("IPhone info: {0}", GSM.IPhone4S);
        }
Ejemplo n.º 20
0
        static void Main()
        {
            Console.WriteLine("For battery type enter \"0\" for NiCd, \"1\" for NiMH, \"2\" for Lead-Acid, \"3\" for Li-ion.");

            Battery bat    = new Battery("Acer", "Prase", 2);
            Display screen = new Display("Acer", "Prase");

            GSM phone = new GSM(screen, bat);

            Console.WriteLine(phone);
        }
Ejemplo n.º 21
0
        public string CalculatePrice()
        {
            GSM someGSM = new GSM(Manufacturer.APPLE, "Iphone4S");

            someGSM.AddCall(new Call(DateTime.Now, "0889", 200));
            someGSM.AddCall(new Call(DateTime.Now, "0886", 400));
            someGSM.AddCall(new Call(DateTime.Now, "0887", 430));

            decimal totalPrice = someGSM.TotalCallPrice(0.37M);
            return string.Format("{0:C}", totalPrice);
        }
Ejemplo n.º 22
0
        public static GSM[] GeneratePhones()
        {
            GSM[] mobilePhones = new GSM[4] {
                                                new GSM("KM900 Arena", "LG", 50, "Gosho", new Battery(Battery.Type.Li_Ion, 10, 200), new Display(3.5f, 16000000)),
                                                new GSM("Google Nexus 4", "LG", 300, "Ivo", new Battery(Battery.Type.Li_Ion, 15, 18), new Display(4.7f, 16000000)),
                                                new GSM("Galaxy S4", "Samsung", 500, "Pesho", new Battery(Battery.Type.Li_Ion, 300, 1), new Display(5.0f, 16000000)),
                                                GSM.IPhone4S
                                            };

            return mobilePhones;
        }
Ejemplo n.º 23
0
        private static void PrintCallHistory(string delimiter, GSM genericGsm)
        {
            foreach (var call in genericGsm.CallHistory)
            {
                Console.WriteLine(delimiter);

                Console.WriteLine("Date: {0}", call.Date);
                Console.WriteLine("Dialed Number: {0}", call.DialedNumber);
                Console.WriteLine("Call Duration: {0}", call.Duration);
            }
        }
Ejemplo n.º 24
0
 private static void PrintDetails(GSM myPhone)
 {
     for (int i = 0; i < myPhone.CallHistory.Count; i++)
     {
         Console.WriteLine("Call #{0}", i + 1);
         Console.WriteLine("Date made: {0}", myPhone.CallHistory[i].DateTime);
         Console.WriteLine("Dialed number: {0}", myPhone.CallHistory[i].NumberDialed);
         Console.WriteLine("Duration in seconds: {0}", myPhone.CallHistory[i].CallDurationInSeconds);
         Console.WriteLine();
     }
 }
Ejemplo n.º 25
0
 private static void PrintDetails(GSM myPhone)
 {
     for (int i = 0; i < myPhone.CallHistory.Count; i++)
     {
         Console.WriteLine("Call #{0}", i + 1);
         Console.WriteLine("Date made: {0}", myPhone.CallHistory[i].DateTime);
         Console.WriteLine("Dialed number: {0}", myPhone.CallHistory[i].NumberDialed);
         Console.WriteLine("Duration in seconds: {0}", myPhone.CallHistory[i].CallDurationInSeconds);
         Console.WriteLine();
     }
 }
Ejemplo n.º 26
0
        public static GSM[] GSMTests()
        {
            GSM[] mobilePhone = new GSM[]
            {
               new GSM("One", "HTC", 850, "Person", new Battery(880, 10, Battery.BatteryModel.LithiumLon), new Display(5, 65000)),
               new GSM("Desire", "HTC", 350, "Person", new Battery(480, 6, Battery.BatteryModel.NiMH), new Display(3, 65000) ),
               new GSM("GSII", "Samsung", 450, "Person", new Battery(980, 7, Battery.BatteryModel.LithiumPolymer), new Display(4, 165000) )
            };

            return mobilePhone;
        }
Ejemplo n.º 27
0
        private static void PrintCallHistory(string delimiter, GSM genericGsm)
        {
            foreach (var call in genericGsm.CallHistory)
            {
                Console.WriteLine(delimiter);

                Console.WriteLine("Date: {0}", call.Date);
                Console.WriteLine("Dialed Number: {0}", call.DialedNumber);
                Console.WriteLine("Call Duration: {0}", call.Duration);
            }
        }
Ejemplo n.º 28
0
        public static GSM[] GeneratePhones()
        {
            GSM[] mobilePhones = new GSM[4] {
                new GSM("KM900 Arena", "LG", 50, "Gosho", new Battery(Battery.Type.Li_Ion, 10, 200), new Display(3.5f, 16000000)),
                new GSM("Google Nexus 4", "LG", 300, "Ivo", new Battery(Battery.Type.Li_Ion, 15, 18), new Display(4.7f, 16000000)),
                new GSM("Galaxy S4", "Samsung", 500, "Pesho", new Battery(Battery.Type.Li_Ion, 300, 1), new Display(5.0f, 16000000)),
                GSM.IPhone4S
            };

            return(mobilePhones);
        }
Ejemplo n.º 29
0
        public string CalculatePrice()
        {
            GSM someGSM = new GSM(Manufacturer.APPLE, "Iphone4S");

            someGSM.AddCall(new Call(DateTime.Now, "0889", 200));
            someGSM.AddCall(new Call(DateTime.Now, "0886", 400));
            someGSM.AddCall(new Call(DateTime.Now, "0887", 430));

            decimal totalPrice = someGSM.TotalCallPrice(0.37M);

            return(string.Format("{0:C}", totalPrice));
        }
Ejemplo n.º 30
0
        static void Main()
        {
            // create test GSM
            string delimiter  = new string('\xA', 3) + new string('-', 35);
            GSM    genericGsm = new GSM("Test model", "Test manufacturer");

            // add calls
            var date1 = new DateTime(2014, 03, 10, 04, 55, 0);
            var date2 = new DateTime(2014, 03, 10, 13, 55, 0);
            var date3 = new DateTime(2014, 03, 10, 18, 55, 0);

            genericGsm.AddCall(new Call(date1, "+359885985678", 90));
            genericGsm.AddCall(new Call(date2, "+359885985678", 120));
            genericGsm.AddCall(new Call(date3, "+359885985678", 70));


            // display calls
            Console.WriteLine("DISPLAY ALL CALLS");
            PrintCallHistory("\nNEXT CALL\n", genericGsm);


            // calculate total price of calls
            Console.WriteLine(delimiter);
            Console.WriteLine("CALCULATE TOTAL BILL");
            Console.WriteLine("Total Bill: {0:0.00}", genericGsm.TotalCallsBill());


            // remove longest call
            Console.WriteLine(delimiter);
            Console.WriteLine("REMOVE LONGEST CALL");
            int maxDuration      = 0;
            int maxDurationIndex = 0;

            for (int i = 0; i < genericGsm.CallHistory.Count; i++)
            {
                if (genericGsm.CallHistory[i].Duration > maxDuration)
                {
                    maxDuration      = genericGsm.CallHistory[i].Duration;
                    maxDurationIndex = i;
                }
            }

            genericGsm.DeleteCall(maxDurationIndex);
            Console.WriteLine("CALCULATE TOTAL BILL");
            Console.WriteLine("Total Bill: {0:0.00}", genericGsm.TotalCallsBill());


            // clear call history and print
            Console.WriteLine(delimiter);
            Console.WriteLine("CLEAR CALL HISTORY AND PRINT");
            genericGsm.ClearCalls();
            PrintCallHistory(delimiter, genericGsm);
        }
Ejemplo n.º 31
0
        public static void Main()
        {
            GSM [] gsmArray = new GSM [3];
            gsmArray[0] = new GSM("Galaxy S5 Plus", "Samsung", 1300, "Piter Pann", new Battery("Samsung 2800mAh", 123, 12, BatteryType.NiMH), new Display(5.1, 16000000));
            gsmArray[1] = new GSM("Z3", "Sony", 990, "Pippi Longstocking", "Sony 3100mAh", 93.8, 52.9, BatteryType.LiIon, 5.2, 16000000);
            gsmArray[2] = GSM.IPhone4S;

            foreach (var gsm in gsmArray)
            {
                Console.WriteLine(gsm.ToString());
            }
        }
        public static GSM GenerateCallHistory(GSM phone)
        {
            phone.AddCall(new Call(new DateTime(2015, 3, 10, 10, 21, 00), "+359888888888", 4));
            phone.AddCall(new Call(new DateTime(2015, 3, 10, 10, 25, 00), "+359888888888", 19));
            phone.AddCall(new Call(new DateTime(2015, 3, 10, 10, 45, 00), "+359133713371", 48));

            phone.AddCall(new Call(new DateTime(2015, 3, 11, 22, 35, 00), "+359555555555", 7));
            phone.AddCall(new Call(new DateTime(2015, 3, 11, 22, 48, 00), "+359666666666", 24));
            phone.AddCall(new Call(new DateTime(2015, 3, 11, 23, 15, 00), "+359888888888", 49));

            return phone;
        }
Ejemplo n.º 33
0
        public static GSM GenerateCallHistory(GSM phone)
        {
            phone.AddCall(new Call(new DateTime(2015, 3, 10, 10, 21, 00), "+359888888888", 4));
            phone.AddCall(new Call(new DateTime(2015, 3, 10, 10, 25, 00), "+359888888888", 19));
            phone.AddCall(new Call(new DateTime(2015, 3, 10, 10, 45, 00), "+359133713371", 48));

            phone.AddCall(new Call(new DateTime(2015, 3, 11, 22, 35, 00), "+359555555555", 7));
            phone.AddCall(new Call(new DateTime(2015, 3, 11, 22, 48, 00), "+359666666666", 24));
            phone.AddCall(new Call(new DateTime(2015, 3, 11, 23, 15, 00), "+359888888888", 49));

            return(phone);
        }
Ejemplo n.º 34
0
        public static void AddCalls(GSM gsm)
        {
            Call[] callArray = new Call[3];
            callArray[0] = new Call(DateTime.Now, "0889123456", 5);
            callArray[1] = new Call(DateTime.Now, "0889123455", 12);
            callArray[2] = new Call(DateTime.Now, "0878536897", 3);

            for (int index = 0; index < callArray.Length; index++)
            {
                gsm.AddCall(callArray[index]);
            }
        }
Ejemplo n.º 35
0
        public static void Main()
        {
            GSM [] gsmArray = new GSM [3];
            gsmArray[0] = new GSM("Galaxy S5 Plus", "Samsung", 1300, "Piter Pann", new Battery("Samsung 2800mAh", 123, 12, BatteryType.NiMH), new Display(5.1, 16000000));
            gsmArray[1] = new GSM("Z3", "Sony", 990, "Pippi Longstocking", "Sony 3100mAh", 93.8, 52.9, BatteryType.LiIon, 5.2, 16000000);
            gsmArray[2] = GSM.IPhone4S;

            foreach (var gsm in gsmArray)
            {
                Console.WriteLine(gsm.ToString());
            }
        }
        public static void StartGSMCallHistoryTest()
        {
            //add mobile phone for test
            Console.WriteLine("GSM for call history test\n");
            GSM testPhone = new GSM("Iphone 8", "", 1699.99m, "Georgi", new Battery(BatteryType.NiMH, 40, 800),
                                    new Display(5.2m, 32000000));

            //add calls made with the test phone
            testPhone.AddCall(DateTime.Today, DateTime.Today.AddSeconds(34));
            testPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(3).AddSeconds(20));
            testPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(5).AddSeconds(2));
            testPhone.AddCall(DateTime.Today, DateTime.Today.AddSeconds(24));
            testPhone.AddCall(DateTime.Now, DateTime.Now.AddMinutes(4));
            testPhone.AddCall(DateTime.Now, DateTime.Now.AddSeconds(57));
            testPhone.AddCall(DateTime.Now, DateTime.Now.AddSeconds(49));
            testPhone.AddCall(DateTime.Now, DateTime.Now.AddMinutes(7).AddSeconds(42));

            //print test phone info
            Console.WriteLine(testPhone);

            //calculate and print price for all calls made with the test phone
            decimal price = testPhone.CalculateAllCallsPrice(0.37m);

            Console.WriteLine("Price for all calls is: {0:f2} lv.\n", price);

            //removing call in position 5 in calls list
            testPhone.RemoveCall(5);
            foreach (Call call in testPhone.CallsList)
            {
                Console.WriteLine(call);
            }
            price = testPhone.CalculateAllCallsPrice(0.37m);
            Console.WriteLine("\nPrice for all calls is: {0:f2} lv.\n", price);

            //removing longest call in calls list
            testPhone.RemoveLongestCall();
            foreach (Call call in testPhone.CallsList)
            {
                Console.WriteLine(call);
            }
            price = testPhone.CalculateAllCallsPrice(0.37m);
            Console.WriteLine("\nPrice for all calls is: {0:f2} lv.\n", price);

            //removing all calls in calls list
            testPhone.RemoveAllCalls();
            foreach (Call call in testPhone.CallsList)
            {
                Console.WriteLine(call);
            }
            price = testPhone.CalculateAllCallsPrice(0.37m);
            Console.WriteLine("Price for all calls is: {0:f2} lv.\n", price);
        }
Ejemplo n.º 37
0
 public static void StartGSMTest()
 {
     GSM[] testArray = new GSM[4];
     testArray[0] = new GSM("6230", "Nokia", 2.34m, "Gosho Peshov", new[] { "Bluetooth", "WI-FI" }, new Battery("Battery for Nokia 6230", 48d, 8d, BatteryType.Li_Ion), new Display(5d, 12000000));
     testArray[1] = new GSM("Edge", "Samsung", 5.34m, "Ivan Ivanov", new[] { "Camera", "WI-FI" }, new Battery("Battery", 48d, 8d, BatteryType.Li_Ion_Polymer), new Display(5.6d, 16000000));
     testArray[2] = new GSM("LG", "Flex", "John", new[] { "Bluetooth", "WI-FI", "Camera" }, new Battery("Some model", BatteryType.Li_Ion_Polymer), new Display(4.7d));
     testArray[3] = new GSM("Iphone", "Apple", "Tim Cook", new[] { "Bluetooth", "WI-FI", "Camera", "GPS", "Force Field" }, new Battery("iPhone battery", BatteryType.Li_Ion_Polymer), new Display(5.2d, 27000000));
     for (int i = 0; i < testArray.Length; i++)
     {
         Console.WriteLine(testArray[i]);
         Console.WriteLine(new string('-', 80));
     }
 }
Ejemplo n.º 38
0
        public static void Test()
        {
            //Create Instance of GSM
            GSM myMobile = new GSM("One", "HTC", 1240, "Pratchett, Terry",
                                   new Display(720, 1280, 4.5, 64000000),
                                   new Battery("2070 mAh", 300, 150, Battery.BatteryTypes.LiIon)
                                   );

            //Add some calls to CallHistory
            Call callOne   = new Call(DateTime.Now, "+898 888 888", 1204);
            Call callTwo   = new Call(DateTime.Now.AddDays(1), "+888 888 898", 1024);
            Call callThree = new Call(DateTime.Now.AddDays(1), "+888 888 898", 200);
            Call callFour  = new Call(DateTime.Now.AddHours(1), "+888 898 898", 2020);

            myMobile.CallHistory.Add(callOne);
            myMobile.CallHistory.Add(callTwo);
            myMobile.CallHistory.Add(callThree);
            myMobile.CallHistory.Add(callFour);


            //Display the information about the calls
            Console.WriteLine("All calls information\n");
            foreach (Call item in myMobile.CallHistory)
            {
                Console.WriteLine(item);
            }

            //Assuming that the price per minute is 0.37 calculate and print
            //the total price of the calls in the history.
            Console.WriteLine("Calculate price example: ");
            var pricePerMinute = 0.37m;

            Console.WriteLine("Price of all calls {0:c}", myMobile.CallculatePrice(pricePerMinute));

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

            //find the longest call
            Call longestCall = FindLongestCall(myMobile);

            //remove the longest call
            myMobile.RemoveCall(longestCall);

            //calculate the price again and print it
            Console.WriteLine("Price after removing longest call: {0:c}", myMobile.CallculatePrice(pricePerMinute));

            //Finally clear the call history and print it.
            Console.WriteLine("\nBefore clear call history stores {0} items", myMobile.CallHistory.Count);
            myMobile.ClearCallHistory();
            Console.WriteLine("Now call history stores {0} items", myMobile.CallHistory.Count);
        }
        public static void GSMCallHistoryTest()
        {
            GSM testCalls = new GSM("WildFire", "HTC", 150, "Ivan", new Battery(BatteryType.LiIon));

            testCalls.AddCall(new DateTime(2015, 7, 26, 15, 15, 26), "+359889653420", 88);
            testCalls.AddCall(new DateTime(2015, 7, 26, 16, 16, 16), "+359824568420", 64);
            testCalls.AddCall(new DateTime(2015, 7, 26, 15, 31, 59), "+359862487258", 1360);
            testCalls.AddCall(new DateTime(2015, 7, 26, 16, 0, 10), "+359883426864", 366);

            Console.WriteLine("Call history");

            foreach (var item in testCalls.CallHistory)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("Total price for all calls:{0}", testCalls.CallPrice((decimal)0.37));
            Console.WriteLine();
            Console.WriteLine("After removing the longest call...");

            int longestIndex = 0;
            int time = 0;

            for (int i = 0; i < testCalls.CallHistory.Count; i++)
            {
                if (testCalls.CallHistory[i].Time > time)
                {
                    time = testCalls.CallHistory[i].Time;
                    longestIndex = i;
                }
            }

            testCalls.DeleteCall(longestIndex);

            foreach (var item in testCalls.CallHistory)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("Total price of call history:{0}", testCalls.CallPrice(0.37m));
            Console.WriteLine("Deleting the call history...");
            testCalls.CallHistoryClear();
            Console.WriteLine();
            Console.WriteLine("Call history:");

            foreach (var item in testCalls.CallHistory)
            {
                Console.WriteLine(item);
            }
        }
Ejemplo n.º 40
0
        public string TestCallsAdding()
        {
            GSM myGSM = new GSM(Manufacturer.NOKIA, "3310");

            myGSM.AddCall(new Call(DateTime.Now, "0889", 200));
            myGSM.AddCall(new Call(DateTime.Now, "0886", 300));

            StringBuilder result = new StringBuilder();

            foreach (var call in myGSM.Calls)
            {
                result.AppendLine(call.ToString());
            }
            return result.ToString();
        }
Ejemplo n.º 41
0
        public string TestCallsAdding()
        {
            GSM myGSM = new GSM(Manufacturer.NOKIA, "3310");

            myGSM.AddCall(new Call(DateTime.Now, "0889", 200));
            myGSM.AddCall(new Call(DateTime.Now, "0886", 300));

            StringBuilder result = new StringBuilder();

            foreach (var call in myGSM.Calls)
            {
                result.AppendLine(call.ToString());
            }
            return(result.ToString());
        }
Ejemplo n.º 42
0
        private static void Main()
        {
            GSM test = new GSM("1100", "Nokia", "BL-5C", BatteryType.LiIon, 15, 320, 1.5, 2, 154.3M, "Pesho");

            Console.WriteLine(test);
            test = new GSM("3310", "Nokia");
            Console.WriteLine();
            Console.WriteLine(test);
            test = new GSM("6310", "Nokia", "BL-6P", null, null, null, null, null, null, "Peter");
            Console.WriteLine();
            Console.WriteLine(test);
            test = new GSM("1600", "Nokia", "BL-5C", 1.5);
            Console.WriteLine();
            Console.WriteLine(test);
            test = GSM.IPhone4S;
            Console.WriteLine();
            Console.WriteLine(test);

            Console.WriteLine("ARRAY TEST");
            GSM[] shop =
            {
                new GSM("1100", "Nokia",  "BL-5C",    BatteryType.LiIon,   15,  320,  1.5,    2, 154.3M, "Pesho"),
                new GSM("3310", "Nokia"),
                new GSM("6310", "Nokia",  "BL-6P",    null,              null, null, null, null, null,   "Gosho"),
                new GSM("Hero", "HTC",    "Built-In", 3.7)
            };

            foreach (var gsm in shop)
            {
                Console.WriteLine(gsm);
            }

            test.CallHistoryAdd(new Call(DateTime.Now, "+359888845652", 20));
            test.CallHistoryAdd(new Call(DateTime.Now.AddMinutes(32), "0885005852", 98));
            test.CallHistoryAdd(new Call(DateTime.Now.AddHours(2), "+359898588885", 320));
            test.CallHistoryAdd(new Call(DateTime.Now.AddDays(1), "5552356", 12));
            Console.WriteLine(test.CallHistoryToString());
            Console.WriteLine("{0:C}", test.TotalPrice(0.37M));

            test.CallHistoryDelAt(test.PositionOfLongestCall());
            Console.WriteLine(test.CallHistoryToString());
            Console.WriteLine("{0:C}", test.TotalPrice(0.37M));

            // test.CallHistoryDeleteLast();
            // test.CallHistoryDelAt(1);
            test.CallHistoryClear();
            Console.WriteLine(test.CallHistoryToString());
        }
Ejemplo n.º 43
0
        public static void TestCallHistory()
        {
            GSM motorola = new GSM("nexus", "Motorola", 500, "comapny phone", new Battery(BatteryType.NiCd), new Display(5, 2000));
            GSM newBrand = new GSM("SSD", "MegaHyper");

            motorola.AddCall(new Call("12/03/2015", "05:34", "0889888888", 100));
            motorola.AddCall(new Call("02.02.2012", "12:34", "0999999999", 140));
            motorola.AddCall(new Call("12.30.2012", "00:34", "0999999999", 12));
            ShowCalls(motorola.calls);
            Console.WriteLine("The Total Price is {0}", motorola.CalculateTotalPrice());
            motorola.FindAndRemoveLongestCall();
            Console.WriteLine("Longest call now removed");
            Console.WriteLine("The Total Price is {0:F2}", motorola.CalculateTotalPrice());
            motorola.ClearHistory();
            Console.WriteLine("Call history deleted");
        }
Ejemplo n.º 44
0
        public static GSM[] GenerateGSMs(int number)
        {
            GSM[] gsms = new GSM[number];

            for (int i = 0; i < number; i++)
            {
                int col = rnd.Next(0, manufacturerAndModels.GetLength(1));
                int row = rnd.Next(1, manufacturerAndModels.GetLength(0));

                gsms[i] = new GSM(manufacturerAndModels[0, col], manufacturerAndModels[row, col], rnd.Next(1, 2001),
                    owners[rnd.Next(0, owners.Length)], batteries[rnd.Next(0, batteries.Length)],
                    display[rnd.Next(0,display.Length)], new List<Call>());
            }

            return gsms;
        }
Ejemplo n.º 45
0
        public GSMTest()
        {
            this.allgsm = new List <GSM>();

            for (int i = 0; i < 3; i++)
            {
                var inputLine = Console.ReadLine().Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray();

                var model        = inputLine[0];
                var manufacturer = inputLine[1];

                GSM currGSM = new GSM(model, manufacturer);

                allgsm.Add(currGSM);
            }
        }
Ejemplo n.º 46
0
        public static void Main()
        {
            try
            {
                Display display = new Display(4, 16000000);
                Battery battery = new Battery(620, 8, Battery.BatteryModel.NiMH);
                GSM phone = new GSM("One", "HTC", 850, "Person", battery, display);

                GSMTest test = new GSMTest();
                Console.WriteLine("=============");
                test.GSMTesting();
                Console.WriteLine("=============");

                DateTime time = new DateTime();
                time = DateTime.Now;

                Calls[] call = new Calls[5];

                //making some phone calls
                for (int i = 0; i < 5; i++)
                {
                    time = time.AddDays(i);
                    string phoneNumber = "0888999999";
                    int duration = i + 100;
                    call[i] = new Calls(time, phoneNumber, duration);
                    phone.AddCall(call[i]);
                }

                Console.WriteLine();
                decimal pricePerMinute = 0.37m;

                //display call information
                phone.CallHistory();
                Console.WriteLine("=============");
                phone.TotalPriceOfCalls(pricePerMinute);
                Console.WriteLine("=============");
                phone.FindLongestCall();
                phone.TotalPriceOfCalls(pricePerMinute);
                Console.WriteLine("=============");
                phone.ClearCallHistory();
                phone.CallHistory();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 47
0
        private static void Main()
        {
            GSM test = new GSM("1100", "Nokia", "BL-5C", BatteryType.LiIon, 15, 320, 1.5, 2, 154.3M, "Pesho");
            Console.WriteLine(test);
            test = new GSM("3310", "Nokia");
            Console.WriteLine();
            Console.WriteLine(test);
            test = new GSM("6310", "Nokia", "BL-6P", null, null, null, null, null, null, "Peter");
            Console.WriteLine();
            Console.WriteLine(test);
            test = new GSM("1600", "Nokia", "BL-5C", 1.5);
            Console.WriteLine();
            Console.WriteLine(test);
            test = GSM.IPhone4S;
            Console.WriteLine();
            Console.WriteLine(test);

            Console.WriteLine("ARRAY TEST");
            GSM[] shop = 
            {
                new GSM("1100", "Nokia", "BL-5C", BatteryType.LiIon, 15, 320, 1.5, 2, 154.3M, "Pesho"),
                new GSM("3310", "Nokia"),
                new GSM("6310", "Nokia", "BL-6P", null, null, null, null, null, null, "Gosho"),
                new GSM("Hero", "HTC", "Built-In", 3.7)
            };

            foreach (var gsm in shop)
            {
                Console.WriteLine(gsm);
            }

            test.CallHistoryAdd(new Call(DateTime.Now, "+359888845652", 20));
            test.CallHistoryAdd(new Call(DateTime.Now.AddMinutes(32), "0885005852", 98));
            test.CallHistoryAdd(new Call(DateTime.Now.AddHours(2), "+359898588885", 320));
            test.CallHistoryAdd(new Call(DateTime.Now.AddDays(1), "5552356", 12));
            Console.WriteLine(test.CallHistoryToString());
            Console.WriteLine("{0:C}", test.TotalPrice(0.37M));

            test.CallHistoryDelAt(test.PositionOfLongestCall());
            Console.WriteLine(test.CallHistoryToString());
            Console.WriteLine("{0:C}", test.TotalPrice(0.37M));

            // test.CallHistoryDeleteLast();
            // test.CallHistoryDelAt(1);
            test.CallHistoryClear();
            Console.WriteLine(test.CallHistoryToString());
        }
Ejemplo n.º 48
0
        static void Main()
        {
            // create test GSM
            string delimiter = new string('\xA', 3) + new string('-', 35);
            GSM genericGsm = new GSM("Test model", "Test manufacturer");

            // add calls
            var date1 = new DateTime(2014, 03, 10, 04, 55, 0);
            var date2 = new DateTime(2014, 03, 10, 13, 55, 0);
            var date3 = new DateTime(2014, 03, 10, 18, 55, 0);
            genericGsm.AddCall(new Call(date1, "+359885985678", 90));
            genericGsm.AddCall(new Call(date2, "+359885985678", 120));
            genericGsm.AddCall(new Call(date3, "+359885985678", 70));

            // display calls
            Console.WriteLine("DISPLAY ALL CALLS");
            PrintCallHistory("\nNEXT CALL\n", genericGsm);

            // calculate total price of calls
            Console.WriteLine(delimiter);
            Console.WriteLine("CALCULATE TOTAL BILL");
            Console.WriteLine("Total Bill: {0:0.00}", genericGsm.TotalCallsBill());

            // remove longest call
            Console.WriteLine(delimiter);
            Console.WriteLine("REMOVE LONGEST CALL");
            int maxDuration = 0;
            int maxDurationIndex = 0;
            for (int i = 0; i < genericGsm.CallHistory.Count; i++)
            {
                if (genericGsm.CallHistory[i].Duration > maxDuration)
                {
                    maxDuration = genericGsm.CallHistory[i].Duration;
                    maxDurationIndex = i;
                }
            }

            genericGsm.DeleteCall(maxDurationIndex);
            Console.WriteLine("CALCULATE TOTAL BILL");
            Console.WriteLine("Total Bill: {0:0.00}", genericGsm.TotalCallsBill());

            // clear call history and print
            Console.WriteLine(delimiter);
            Console.WriteLine("CLEAR CALL HISTORY AND PRINT");
            genericGsm.ClearCalls();
            PrintCallHistory(delimiter, genericGsm);
        }
        public static void GSMTesting()
        {
            GSM test1 = new GSM("6303", "Nokia", 80, "Ivan");
            GSM test2 = new GSM("CoreDuos", "Samsung", 360, "Koicho");
            GSM test3 = new GSM("WildFire", "HTC", 150, "Ivan", new Battery(BatteryType.LiIon));
            GSM test4 = new GSM("A60", "Siemens", 18, "Stamat", new Battery(BatteryType.NiCd, 72, 4));

            GSM[] tests = { test1, test2, test3, test4 };

            foreach (var item in tests)
            {
                Console.WriteLine(item);
                Console.WriteLine();
            }

            Console.WriteLine(GSM.IPhone4S);
        }
Ejemplo n.º 50
0
        static void Main()
        {
            //create a test instance & add 3 calls
            var gsmTest = new GSM("nokia", "test model");

            gsmTest.AddCall(new Call(new DateTime(2015, 12, 31, 10, 00, 00), "0888123456", 61));
            gsmTest.AddCall(new Call(new DateTime(2016, 12, 31, 10, 15, 00), "0888666555", 333));
            gsmTest.AddCall(new Call(new DateTime(2017, 01, 01, 00, 00, 01), "0888123456", 60));


            //test call price calculations
            Console.WriteLine("Test call price calculation method\r\n==========================================");
            Console.WriteLine("Total Calls Count: {0}", gsmTest.CallHistory.Count);
            Console.WriteLine("Total Price: {0: 0.00}", gsmTest.CallPrice(0.37M));
            Console.WriteLine();

            //print initial state of the instance
            Console.WriteLine("Initial state of the gsmTest object\r\n==========================================\r\n{0}", gsmTest);

            //delete the longest call
            int indexLongestCall = -1;
            int maxSeconds       = 0;

            foreach (var call in gsmTest.CallHistory)
            {
                if (call.Duration > maxSeconds)
                {
                    maxSeconds = (int)call.Duration;
                    indexLongestCall++;
                }
            }
            gsmTest.DeleteCall(indexLongestCall);

            //print price without longest call
            Console.WriteLine("\r\nPrice calculation without the longest call\r\n==========================================");
            Console.WriteLine("Total Calls Count: {0}", gsmTest.CallHistory.Count);
            Console.WriteLine("Total Price: {0: 0.00}\r\n", gsmTest.CallPrice(0.37M));
            Console.WriteLine("gsmTest object without the longest call\r\n==========================================\r\n{0}", gsmTest);

            //print the final state of the instance

            //clear the history
            gsmTest.ClearHistory();

            Console.WriteLine("gsmTest object with cleared history\r\n==========================================\r\n{0}", gsmTest);
        }
Ejemplo n.º 51
0
        public string TestMobilePhoneCreation()
        {
            Battery myBattery = new Battery("Some Battery");
            myBattery.HoursIdle = 100;
            myBattery.HoursTalk = 200;
            myBattery.Type = BatteryType.LiPoly;

            Display myDisplay = new Display();
            myDisplay.Colors = 2000;
            myDisplay.Size = 5.0;

            GSM myGSM = new GSM(Manufacturer.SAMSUNG, "Note 3", myBattery, myDisplay);
            myGSM.Owner = "Pesho";
            myGSM.Price = 400.0M;

            return myGSM.ToString();
        }
Ejemplo n.º 52
0
        static void Main(string[] args)
        {
            //zad.7
            GSMTest.PrintInfo();

            //Create an instance of the GSM class.
            GSM myPhone = new GSM("N95", "Nokia");

            //Add few calls.
            Call call = new Call(DateTime.Now, "0883333333", 60);
            Call nextCall = new Call(new DateTime(2013,02,10,20,34,20), "+3592376541212", 120);
            myPhone.AddCall(call);
            myPhone.AddCall(nextCall);

            //Display the information about the calls.
            foreach (var c in myPhone.CallHistory)
            {
                Console.WriteLine(c);
            }

            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            Console.Write("The total price of the calls is: ");
            myPhone.PriceOfCalls(0.37m);

            //Remove the longest call from the history and calculate the total price again.
            Call longest = new Call();
            longest.Duration = 0;
            for (int i = 0; i < myPhone.CallHistory.Count; i++)
            {
                if (myPhone.CallHistory[i].Duration > longest.Duration)
                {
                    longest = myPhone.CallHistory[i];
                }
            }
            myPhone.RemoveCall(longest);
            Console.Write("The new price after removing longest call is: ");
            myPhone.PriceOfCalls(0.37m);

            //Finally clear the call history and print it.
            myPhone.ClearCallHistory();
            foreach (var c in myPhone.CallHistory)
            {
                Console.WriteLine(c);
            }
        }
Ejemplo n.º 53
0
        public static void TestGSMClass()
        {
            GSM[]  gsms = new GSM[10];
            Random randomManufacturer = new Random();

            string[] manufacturers = { "Apple", "Samsung", "Lenovo", "Nokia", "LG" };
            for (int i = 0; i < 10; i++)
            {
                gsms[i] = new GSM(i.ToString(), manufacturers[randomManufacturer.Next(0, 5)]);
            }

            foreach (var gsm in gsms)
            {
                Console.WriteLine(gsm);
            }

            Console.WriteLine(GSM.IPhone4S);
        }
Ejemplo n.º 54
0
        private static void GSMTest()
        {
            GSM test1 = new GSM("Nokia", "Connecting People", 140000
                                , "HappyOwner", new Battery("BestBatteryEVER", 1000, 10000, Battery.Type.AlienTech), new Display(4.5m, 16000000));

            GSM test2 = new GSM("Kia", "Thailand");

            GSM test3 = new GSM("Somebrand", "SomeManufacturer", 100, "Az", new Battery(), new Display());

            GSM[] testAll = new GSM[] { test1, test2, test3 };

            foreach (var gsm in testAll)
            {
                Console.WriteLine(gsm);
            }

            Console.WriteLine(GSM.IPhone4S);
        }
Ejemplo n.º 55
0
        private static Call FindLongestCall(GSM gsm)
        {
            if (gsm.CallHistory.Count == 0)
            {
                throw new ArgumentNullException("Call history is empty!");
            }
            Call longest = gsm.CallHistory[0];

            for (int i = 0; i < gsm.CallHistory.Count; i++)
            {
                if (longest.CallDuration < gsm.CallHistory[i].CallDuration)
                {
                    longest = gsm.CallHistory[i];
                }
            }

            return(longest);
        }
Ejemplo n.º 56
0
        static void Main()
        {
            var gsmList = new List <GSM>();

            gsmList.Add(new GSM("nokia", "3310"));
            gsmList.Add(new GSM("lg", "G2", 500.42M));
            gsmList.Add(new GSM("siemens", "C100", 23.45M, "Grisha", "Ganchev"));

            var theIPhone = new GSM(" ", " ");

            theIPhone = theIPhone.IPhone4S;

            for (int i = 0; i < gsmList.Count; i++)
            {
                Console.WriteLine(gsmList[i]);
            }
            Console.WriteLine(theIPhone);
        }
Ejemplo n.º 57
0
        public static void CreateListOfPhones()
        {
            List <GSM> phoneList = new List <GSM>();

            GSM gsmOne   = new GSM("Nokia", "с фенерче", "Майор Костов", 50, new Display(2.0, "b/w"), new Battery(), new List <Call>());
            GSM gsmTwo   = new GSM("айфон", "новия", "чорбаджия", 1500, new Display(), new Battery(), new List <Call>());
            GSM gsmThree = new GSM("LG", "с капаче", "Батман", 200, new Display(), new Battery(), new List <Call>());

            phoneList.Add(gsmOne);
            phoneList.Add(gsmTwo);
            phoneList.Add(gsmThree);

            foreach (var phone in phoneList)
            {
                Console.WriteLine(phone.ToString());
                Console.WriteLine(new string('-', 40));
            }
        }
Ejemplo n.º 58
0
        public static void CreateCallHistory()
        {
            GSM testgsm = new GSM();

            Call callOne   = new Call(new DateTime(2015, 02, 03), new DateTime(2015, 02, 03, 14, 05, 25), "private number", 23);
            Call callTwo   = new Call(new DateTime(2015, 02, 03), new DateTime(2015, 02, 03, 17, 14, 38), "private number", 701);
            Call callThree = new Call(new DateTime(2015, 02, 04), new DateTime(2015, 02, 03, 10, 02, 45), "private number", 411);

            //Add few calls
            Console.WriteLine("Added few calls");
            testgsm.CallHistory.Add(callOne);
            testgsm.CallHistory.Add(callTwo);
            testgsm.CallHistory.Add(callThree);



            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Initial number of calls: {0}", testgsm.CallHistory.Count);
            Console.WriteLine("Price of the calls: " + testgsm.CalculateCallPrice());
            Console.WriteLine("Longest call: {0}", testgsm.FindLongestCall().Duration);

            Console.WriteLine("\nAdd a new call");
            testgsm.AddCall(new Call(new DateTime(2015, 02, 04), new DateTime(2015, 02, 03, 10, 33, 45), "private number", 806));
            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Number of calls: {0}", testgsm.CallHistory.Count);
            Console.WriteLine("Price of the calls: " + testgsm.CalculateCallPrice());
            Console.WriteLine("Longest call: {0}", testgsm.FindLongestCall().Duration);

            //Delete longest call
            testgsm.DeleteCall(testgsm.CallHistory.IndexOf(testgsm.FindLongestCall()));
            Console.WriteLine("\nDelete longest call");
            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Number of calls: {0}", testgsm.CallHistory.Count);
            Console.WriteLine("Price of the calls: " + testgsm.CalculateCallPrice());
            Console.WriteLine("Longest call: {0}", testgsm.FindLongestCall().Duration);

            Console.WriteLine("\nDelete all call history");
            testgsm.DeleteAllHistory();
            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Number of calls: {0}", testgsm.CallHistory.Count);


            Console.WriteLine(testgsm.CallHistory.Count);
        }
Ejemplo n.º 59
0
        public string TestMobilePhoneCreation()
        {
            Battery myBattery = new Battery("Some Battery");

            myBattery.HoursIdle = 100;
            myBattery.HoursTalk = 200;
            myBattery.Type      = BatteryType.LiPoly;

            Display myDisplay = new Display();

            myDisplay.Colors = 2000;
            myDisplay.Size   = 5.0;

            GSM myGSM = new GSM(Manufacturer.SAMSUNG, "Note 3", myBattery, myDisplay);

            myGSM.Owner = "Pesho";
            myGSM.Price = 400.0M;

            return(myGSM.ToString());
        }
        public static void CallHistorySimulation()
        {
            GSM htcMini = new GSM("One mini", "HTC", 400, "Ivan", new Battery(BatteryType.LiPol, null, 400, 60), new Display(4.3, "16M"));

            htcMini.AddCall(DateTime.Today, DateTime.Today.AddMinutes(10), "1234567890");
            htcMini.AddCall(DateTime.Today, DateTime.Today.AddMinutes(20), "1234567890");
            htcMini.AddCall(DateTime.Today, DateTime.Today.AddSeconds(10), "1234567890");
            htcMini.AddCall(DateTime.Today, DateTime.Today.AddSeconds(0), "1234567890");
            htcMini.AddCall(DateTime.Today, DateTime.Today.AddSeconds(48), "1234567890");

            Console.WriteLine("Call history\n");
            Console.WriteLine(htcMini);
            Console.WriteLine("Total price: {0:F2}\n", htcMini.TotalAmountOfCalls(0.37));
            htcMini.DeleteLongestCall();
            Console.WriteLine("After remove longest call\n");
            Console.WriteLine(htcMini);
            Console.WriteLine("Total price: {0:F2}\n", htcMini.TotalAmountOfCalls(0.37));
            Console.WriteLine("After clear call history\n");
            htcMini.DeleteAllCalls();
            Console.WriteLine(htcMini);
        }