public void TestHistoryDisplay()
        {
            GSM      phone = new GSM("lala", "sumsAng", "batman", 10000.99);
            DateTime date  = new DateTime();

            DateTime.TryParse("2.2.2013 14:34", out date);
            phone.MakeCall(date, "0899999999", 3.44);

            DateTime.TryParse("6.2.2013 19:34:11", out date);
            phone.MakeCall(date, "0899999999", 3.44);

            DateTime.TryParse("11.2.2013 12:32:59", out date);
            phone.MakeCall(date, "0889666999", 9.44);

            DateTime.TryParse("12.2.2013 15:30:00", out date);
            phone.MakeCall(date, "0009666999", 9.44);

            string expected = @"12-Feb-13 15:30:00
11-Feb-13 12:32:59
06-Feb-13 19:34:11
02-Feb-13 14:34:00
";

            StringBuilder sb = new StringBuilder();

            foreach (var item in phone.GetCallsByDate())
            {
                sb.AppendLine(item.ToString());
            }

            Assert.AreEqual(expected, sb.ToString());
        }
Exemple #2
0
        public void TestMethod1()
        {
            GSM      newTestGsm = new GSM();
            DateTime date1      = DateTime.Now;

            newTestGsm.CallHistory.Add(new Call(date1, 0878547866, 180, "Kiril"));
            newTestGsm.CallHistory.Add(new Call(date1, 0878256567, 120, "Tosho"));
            newTestGsm.CallHistory.Add(new Call(date1, 0898321455, 120, "Ogi"));
            newTestGsm.CallHistory.Add(new Call(date1, 0878547866, 240, "Kiril"));

            Assert.AreEqual(4.07m, newTestGsm.CalculateTotalPrice(0.37m));

            newTestGsm.RemoveCallMaxValue();
            Assert.AreEqual(2.59m, newTestGsm.CalculateTotalPrice(0.37m));

            newTestGsm.RemoveCallMinValue();
            Assert.AreEqual(1.85m, newTestGsm.CalculateTotalPrice(0.37m));
        }
Exemple #3
0
        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");
            }
        }
Exemple #4
0
        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");
            }
        }
        public void TestCallRate()
        {
            GSM phone = new GSM("lala", "sumsAng", "batman", 10000.99);

            phone.MakeCall(DateTime.Now, "0899999999", 3.44);
            phone.MakeCall(DateTime.Now, "0899999999", 3.44);
            phone.MakeCall(DateTime.Now, "0889666999", 9.44);
            phone.MakeCall(DateTime.Now, "0009666999", 9.44);

            phone.setCallRate = 0.37;

            Assert.AreEqual("9.5312", Convert.ToString(phone.CalculateTotalPriceOfCalls()));

            phone.DeleteCall(3);
            Assert.AreEqual("6.0384", Convert.ToString(phone.CalculateTotalPriceOfCalls()));

            phone.ClearCallHistory();
            Assert.AreEqual("0", Convert.ToString(phone.CalculateTotalPriceOfCalls()));
        }
Exemple #6
0
        static void Main()
        {
            //Create an instance of the GSM class.

            GSM nokiaN70 = new GSM(null, null);

            nokiaN70.Battery                = new Battery("batt87", 35.5, 3);
            nokiaN70.gsmBattery             = new Battery("batt87", 35.5, 3);
            nokiaN70.iPhone4s               = new GSM("iphone", "apple");
            nokiaN70.PhoneManufacturer      = "Nokia Corp.";
            nokiaN70.PhoneModel             = "N70";
            nokiaN70.PhoneOwner             = "bai ganio";
            nokiaN70.PhonePrice             = 1.01m;
            nokiaN70.Call.CallDuration      = 410;
            nokiaN70.Call.DialedPhoneNumber = 0888123456;

            //Add few calls.
            GSM nokia = new GSM(null, null);

            nokia.Battery                = new Battery("batt87", 35.5, 3);
            nokia.gsmBattery             = new Battery("batt87", 35.5, 3);
            nokia.iPhone4s               = new GSM("iphone", "apple");
            nokia.PhoneManufacturer      = "Nokia Corp.";
            nokia.PhoneModel             = "N70";
            nokia.PhoneOwner             = "bai ganio";
            nokia.PhonePrice             = 1.01m;
            nokia.Call.CallDuration      = 410;
            nokia.Call.DialedPhoneNumber = 0888123456;
            GSM.callHistory.Add(nokia.Call); //leave no null characteristics - fill all battery, owner etc.

            GSM htc = new GSM(null, null);

            htc.Battery                = new Battery("batt87", 30.5, 3.2);
            htc.gsmBattery             = new Battery("batt87", 35.1, 0.3);
            htc.iPhone4s               = new GSM("iphone", "apple");
            htc.PhoneManufacturer      = "HTC Corp.";
            htc.PhoneModel             = "One";
            htc.PhoneOwner             = "bash ganio";
            htc.PhonePrice             = 1.06m;
            htc.Call.CallDuration      = 110;
            htc.Call.DialedPhoneNumber = 0877123456;
            GSM.callHistory.Add(htc.Call);

            GSM sony = new GSM(null, null);

            sony.Battery                = new Battery("batt87", 25.5, 1.3);
            sony.gsmBattery             = new Battery("batt87", 35.5, 3);
            sony.iPhone4s               = new GSM("iphone", "apple");
            sony.PhoneManufacturer      = "Sony Corp.";
            sony.PhoneModel             = "Something";
            sony.PhoneOwner             = "ganio";
            sony.PhonePrice             = 1.08m;
            sony.Call.CallDuration      = 210;
            sony.Call.DialedPhoneNumber = 0899123456;
            GSM.callHistory.Add(sony.Call);

            GSM samsung = new GSM(null, null);

            samsung.Battery                = new Battery("batt817", 15.5, 4.3);
            samsung.gsmBattery             = new Battery("batt817", 35.5, 3);
            samsung.iPhone4s               = new GSM("iphone", "apple");
            samsung.PhoneManufacturer      = "samsung Corp.";
            samsung.PhoneModel             = "s520";
            samsung.PhoneOwner             = "one more ganio";
            samsung.PhonePrice             = 111.00m;
            samsung.Call.CallDuration      = 262;
            samsung.Call.DialedPhoneNumber = 0882111111;
            //GSM.callHistory.Add(samsung.Call);
            GSM.AddCallsToHistory(samsung.Call);


            //Display the information about the calls.
            foreach (var call in GSM.CallHistory)
            {
                Console.WriteLine("Call number: {0}", call.DialedPhoneNumber);
                Console.WriteLine("Call date: {0}", call.Date.ToShortDateString());
                Console.WriteLine("Call time: {0}", call.Time.ToShortTimeString());
                Console.WriteLine("Call duration: {0}", call.CallDuration);
                Console.WriteLine();
            }

            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            GSM.CalculateTotalCallsCost(GSM.callHistory, 0.37m); //pass current call log and call price pre minute in decimal

            //Remove the longest call from the history and calculate the total price again.
            // - sort and find longest call
            var longest = from call in GSM.callHistory
                          orderby call.CallDuration
                          select call;

            // - remove it from the list
            GSM.RemoveCallsFromHistory(longest.Last());
            // - calculate new total call log worth
            Console.WriteLine("After removing longest call in the log: ");
            GSM.CalculateTotalCallsCost(longest.ToList(), 0.37m);

            //Finally clear the call history and print it.
            Console.WriteLine("Call log is cleared: ");
            GSM.ClearCallsHistory();

            Console.WriteLine("--------");
            foreach (var call in GSM.CallHistory)
            {
                Console.WriteLine("Call number: {0}", call.DialedPhoneNumber);
                Console.WriteLine("Call date: {0}", call.Date.ToShortDateString());
                Console.WriteLine("Call time: {0}", call.Time.ToShortTimeString());
                Console.WriteLine("Call duration: {0}", call.CallDuration);
                Console.WriteLine();
            }
            Console.WriteLine("--------");
        }
Exemple #7
0
 static GSM()
 {
     iphone4S = new GSM("4S", "Apple");
 }
Exemple #8
0
 static GSM()
 {
     iphone4S = new GSM("4S", "Apple");
 }