Beispiel #1
0
        public static void TestExecutor()
        {
            var myGSM = new GSM("Xperia Z1", "Sony", 559.99, "Lyudmil Nikodimov",
                                new Battery(BatteryType.LiPoly, "25:00", "06:45"),
                                new Display(5.0, 16000000), new List <Call>());

            myGSM.AddCall(new Call(new DateTime(2015, 03, 23), "+4915209892427", 234.34));
            myGSM.AddCall(new Call(new DateTime(2015, 01, 19), "+4965464566425", 145.78));
            myGSM.AddCall(new Call(new DateTime(2015, 02, 16), "+4921542848464", 478.41));

            foreach (var call in myGSM.CallHistory)
            {
                Console.WriteLine(call);
            }

            Console.WriteLine(myGSM.CalculateOverallCallPrice(0.37M));
            myGSM.DeleteCall(myGSM.CallHistory.Last());
            Console.WriteLine(myGSM.CalculateOverallCallPrice(0.37M));
            myGSM.ClearCallHistory();

            foreach (var call in myGSM.CallHistory)
            {
                Console.WriteLine(call);
            }
        }
Beispiel #2
0
        static GSMCallHistoryTest()
        {
            GSMSample = new GSM("Lenovo S1 Light", "Lenovo", 300, 61989,
                                new Battery("61C00", BatteryType.Li_Ion),
                                new Display(3, 1280));


            GSMSample.CallHistory.AddLast(new Call(new DateTime(2016, 01, 17, 16, 30, 17), 512, "+359876584721"));
            GSMSample.CallHistory.AddLast(new Call(new DateTime(2016, 02, 1, 3, 25, 00), 512, "+359876584721"));
            GSMSample.CallHistory.AddLast(new Call(new DateTime(2016, 01, 17, 16, 30, 17), 512, "+359876584721"));
        }
Beispiel #3
0
        public GSMTest(int number, GSM[] gsmArray)
        {
            this.numberOfInstances = number;
            this.gsmArray = gsmArray;

            foreach (GSM gsm in gsmArray)
            {
                Console.WriteLine(gsm.ToString());

            }

            Console.WriteLine(GSM.iPhone4S);
        }
Beispiel #4
0
        static void Main()
        {
            GSM gsmInstance1 = new GSM("Galaxy", "Samsung");
            GSM gsmInstance2 = new GSM("Galaxy", "Samsung", 1200, "Samsung", new Battery(), new Display());

            GSM[] gsmInstances =  {gsmInstance1, gsmInstance2};

            for (int i = 0; i < 2; i++)
            {
                Console.WriteLine(gsmInstances[i]);
                Console.WriteLine("------------------");
            }
        }
        /*Write a class GSMCallHistoryTest to test the call history functionality of the GSM class.

        Create an instance of the GSM class.
        Add few calls.
        Display the information about the calls.
        Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
        Remove the longest call from the history and calculate the total price again.
        Finally clear the call history and print it.
        */
        static void Main(string[] args)
        {
            GSM gsm = new GSM("someModel", "Nokia");

            Console.WriteLine("Enter number of calls: ");
            int numberOfCalls = int.Parse(Console.ReadLine());
            Random rnd = new Random();
            string dialledNumber = "088";

            for (int i = 0; i < numberOfCalls; i++)
            {
                DateTime startCall = DateTime.Now.AddMinutes(rnd.Next(40000));
                Calls newCall = new Calls(startCall, startCall.AddSeconds(rnd.Next(0, 360)), dialledNumber + rnd.Next(9999999).ToString());
                gsm.AddCalls(newCall);

            }

            foreach (Calls call in gsm.CallHistory)
            {
                Console.WriteLine("Call info: \n Date of call: {0:MM/dd/yyyy} \n Time of call: {1:hh:mm:ss} \n Duration: {2} seconds \n Dialled Number: {3}", call.timeAndDateOfCall, call.timeAndDateOfCall,
                    call.duration, call.dialledNumber);

            }

            Console.WriteLine();
            Console.WriteLine("Total costs: {0:C}", gsm.CalculatePrice());

            double bestDuration = 0;
            int bestIndex = 0;
            for (int i = 0; i < gsm.CallHistory.Count; i++)
            {
                if (gsm.CallHistory[i].duration > bestDuration)
                {
                    bestIndex = i;
                }
            }

            gsm.DeleteCalls(bestIndex);
            Console.WriteLine();
            Console.WriteLine("Total costs after removing longest duration call: {0:C}", gsm.CalculatePrice());

            gsm.ClearCallHistory();
            if (gsm.CallHistory.Count < 1)
            {
                Console.WriteLine();
                Console.WriteLine("Call history successfully deleted.");
            }
        }
		public static void TestExecutor()
		{
			var myGSM = new GSM("Xperia Z1", "Sony", 559.99, "Lyudmil Nikodimov",
																				new Battery(BatteryType.LiPoly, "25:00", "06:45"),
																				new Display(5.0, 16000000), new List<Call>());
			myGSM.AddCall(new Call(new DateTime(2015, 03, 23), "+4915209892427", 234.34));
			myGSM.AddCall(new Call(new DateTime(2015, 01, 19), "+4965464566425", 145.78));
			myGSM.AddCall(new Call(new DateTime(2015, 02, 16), "+4921542848464", 478.41));

			foreach (var call in myGSM.CallHistory)
			{
				Console.WriteLine(call);
			}

			Console.WriteLine(myGSM.CalculateOverallCallPrice(0.37M));
			myGSM.DeleteCall(myGSM.CallHistory.Last());
			Console.WriteLine(myGSM.CalculateOverallCallPrice(0.37M));
			myGSM.ClearCallHistory();

			foreach (var call in myGSM.CallHistory)
			{
				Console.WriteLine(call);
			}
		}
Beispiel #7
0
 static GSM()
 {
     IPhone4S =
         new GSM("IPhone4S", "Apple", 365.99, "Mr. Nobody", new Battery(BatteryType.LiIon, "12:53", "03:34"), new Display(4.5, 16000000), new List <Call>());
 }
Beispiel #8
0
		static GSM()
		{
			IPhone4S =
				new GSM("IPhone4S", "Apple", 365.99, "Mr. Nobody", new Battery(BatteryType.LiIon, "12:53", "03:34"), new Display(4.5, 16000000), new List<Call>());
		}
Beispiel #9
0
 static GSM()
 {
     IPhone4S = new GSM("iPhone 4S", "Apple", 600,
                        battery: new Battery("A1586", BatteryType.Li_Ion),
                        display: new Display(3.5f, 2056));
 }