ClearHistory() public method

public ClearHistory ( ) : void
return void
Exemplo n.º 1
0
    static void Main()
    {
        DateTime date1 = new DateTime(2013, 5, 24, 11, 11, 30);
        DateTime date2 = new DateTime(2013, 5, 24, 15, 23, 2);
        DateTime date3 = new DateTime(2013, 5, 31, 9, 00, 00);
        DateTime date4 = new DateTime(2013, 5, 31, 18, 12, 20);

        Call call1 = new Call(date1, "0888313233", 850);
        Call call2 = new Call(date2, "0888909090", 95);
        Call call3 = new Call(date3, "0889556677", 213);
        Call call4 = new Call(date4, "0888313233", 37);

        Battery battery = new Battery("PX8", BatteryType.LiIon, 300, 8);
        Display display = new Display(4, 16000000);
        GSM     gsm     = new GSM("I900", "Samsung", 500, "Me", battery, display);

        gsm.AddCalls(call1);
        gsm.AddCalls(call2);
        gsm.AddCalls(call3);
        gsm.AddCalls(call4);

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

        Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice);

        gsm.DeleteCalls(call1);
        Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice);

        gsm.ClearHistory();
        Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice);
    }
Exemplo n.º 2
0
    public static void RunTest()
    {
        GSM myPhone = new GSM("HTC Desire", "HTC", 550, "Pesho", new Battery(BatteryType.LiIon), new Display(4, 250000));
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(5), "0887776987");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(8), "0897556644");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(15), "0887441100");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(23), "0885001122");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(4), "0896559988");

        Console.WriteLine(myPhone);
        Console.WriteLine("-----------Call History-----------");
        foreach (Call call in myPhone.CallHistory)
        {
            Console.WriteLine(call);
        }

        Console.WriteLine("Total price of all calls: ${0:F2}", myPhone.TotalCallsCost(0.37));
        myPhone.DeleteLongestCall();
        Console.WriteLine("After the remove of the longest call the total price is: ${0:F2}", myPhone.TotalCallsCost(0.37));
        Console.WriteLine();

        myPhone.ClearHistory();
        Console.WriteLine("-----------Cleared Call History-----------");
        if (myPhone.CallHistory.Count == 0)
        {
            Console.WriteLine("There are no Recorded Calls in the History!");
        }
        else
        {
            foreach (Call call in myPhone.CallHistory)
            {
                Console.WriteLine(call);
            }
        }
    }
    public void HistoryTest()
    {
        Console.WriteLine(new string('-', 50));
        Console.WriteLine("                  Calls history");
        Console.WriteLine(new string('-', 50));
        Console.WriteLine();
        GSM phone = new GSM();
        phone.AddHistory(DateTime.Now, "0891234567", 10);
        phone.AddHistory(DateTime.Now, "0883456789", 47.99);
        phone.AddHistory(DateTime.Now, "0872345678", 89.01);
        phone.PrintCalls();

        Console.WriteLine();
        Console.WriteLine("Assuming the price per minute is 0.37! Calculate the total price of the calls:");
        Console.WriteLine(new string('-', 77));
        phone.CalculateTotalPrice();
        Console.WriteLine();
        Console.WriteLine();

        Console.WriteLine("Delete longest call from the history and calculate the total price again:");
        Console.WriteLine(new string('-', 74));
        phone.DeleteHistory(89.01);
        phone.CalculateTotalPrice();
        Console.WriteLine();
        Console.WriteLine();

        Console.WriteLine(new string('-', 50));
        Console.WriteLine("           Calls history after delete");
        Console.WriteLine(new string('-', 50));
        Console.WriteLine();
        phone.ClearHistory();
        phone.CalculateTotalPrice();
    }
Exemplo n.º 4
0
    static void Main()
    {
        DateTime date1 = new DateTime(2013, 5, 24, 11, 11, 30);
        DateTime date2 = new DateTime(2013, 5, 24, 15, 23, 2);
        DateTime date3 = new DateTime(2013, 5, 31, 9, 00, 00);
        DateTime date4 = new DateTime(2013, 5, 31, 18, 12, 20);

        Call call1 = new Call(date1, "0888313233", 850);
        Call call2 = new Call(date2, "0888909090", 95);
        Call call3 = new Call(date3, "0889556677", 213);
        Call call4 = new Call(date4, "0888313233", 37);

        Battery battery = new Battery ("PX8", BatteryType.LiIon, 300, 8);
        Display display = new Display(4, 16000000);
        GSM gsm = new GSM("I900", "Samsung", 500, "Me", battery, display);

        gsm.AddCalls(call1);
        gsm.AddCalls(call2);
        gsm.AddCalls(call3);
        gsm.AddCalls(call4);

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

        Console.WriteLine("Total amount to pay: {0:C}",gsm.TotalCallsPrice);

        gsm.DeleteCalls(call1);
        Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice);

        gsm.ClearHistory();
        Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice);
    }
Exemplo n.º 5
0
    private static void CallsInfo()
    {
        // 12. Test the call history functionality of the GSM class.
        GSM gsm = new GSM("Optimus", "LG"); // 12.1 Create an instance of the GSM class.

        // 12.2 Add few calls.
        gsm.AddCall(DateTime.Now, 0871111111, 60);
        gsm.AddCall(DateTime.Now, 0882222222, 200);
        gsm.AddCall(DateTime.Now, 0893333333, 1234);

        // 12.3 Display the information about the calls.
        gsm.PrintHistory();

        /* 12.4 Assuming that the price per minute is 0.37
                Calculate and print the total price of the calls in the history. */
        Console.WriteLine("The cost of calls is: {0:C2}", gsm.CallPrice(0.37f));

        // 12.5 Remove the longest call from the history and calculate the total price again.
        gsm.DeleteCall(1234);
        Console.WriteLine("The cost of calls without the longest one is: {0:C2}", gsm.CallPrice(0.37f));

        // 12.6 Finally clear the call history and print it.
        gsm.ClearHistory();
        gsm.PrintHistory();
        Console.WriteLine("History is cleared!" + Environment.NewLine);

        Main();
    }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            GSM gsm = new GSM("Galaxy", "Samsung");
            gsm.AddCall(new Call("+359884211", 1, 0.5));
            gsm.AddCall(new Call("+359884212", 2, 0.5));
            gsm.AddCall(new Call("+359884213", 3, 0.5));
            gsm.AddCall(new Call("+359884214", 4, 0.2));

            Console.WriteLine("Call History:");
            Console.WriteLine();

            foreach (Call call in gsm.CallHistory)
            {
                Console.WriteLine(call);
            }

            Console.WriteLine("Total Calls Price: {0}", gsm.CalculteTotalCallsPrice());

            var longestCall = gsm.CallHistory
                .OrderByDescending(x => x.Duration)
                .First();

            gsm.DeleteCall(longestCall);

            Console.WriteLine("Total Calls Price after longest call is deleted: {0}", gsm.CalculteTotalCallsPrice());

            gsm.ClearHistory();

            if (gsm.CallHistory.Count == 0)
            {
                Console.WriteLine("No calls in calls history available!");
            }
        }
 public void CallHistoryBlankHistory()
 {
     myPhone.ClearHistory();
     foreach (Call call in myPhone.CallHistory)
     {
         Assert.IsNull(call);
     }
 }
Exemplo n.º 8
0
    static void Main()
    {
        // GSMTest
        GSM[] test = new GSM[3];

        Display testDisplay = new Display(12, 13);
        Battery testBattery = new Battery(BatteryType.LiIon, 10, 10);

        GSM firstPhone = new GSM("test", "test", 12, "Shefa Joro", testBattery, testDisplay);

        test[0] = firstPhone;

        GSM secondPhone = new GSM("SecondTest", "SecondTest", 14, "Moore Name", testBattery, testDisplay);

        test[1] = secondPhone;

        GSM thirdPhone = new GSM("Some test", "Texttt", 1, "Name", testBattery, testDisplay);

        test[2] = thirdPhone;

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

        Console.WriteLine(GSM.Iphone.Model);
        Console.WriteLine(GSM.Iphone.Manufacturer);
        Console.WriteLine(firstPhone.Battery.BatteryModel);

        Console.WriteLine("---------------------------------");
        Console.WriteLine("GSMCallHistoryTest");
        Console.WriteLine("---------------------------------");

        //GSMCallHistoryTest
        GSM myPhone = new GSM("Nokia", "Nokia Corp", 1, "Ivan", testBattery, testDisplay);


        myPhone.AddCall(DateTime.Now, "088888888", 236);
        myPhone.AddCall(DateTime.Now, "077777777", 333);
        myPhone.AddCall(DateTime.Now, "066666666", 123);
        myPhone.AddCall(DateTime.Now, "055555555", 11);
        myPhone.AddCall(DateTime.Now, "044444444", 23);

        myPhone.DisplayCallHistory();

        Console.WriteLine(myPhone.CalcPrice(0.37));

        myPhone.RemoveCallByDuration(333);

        myPhone.DisplayCallHistory();
        Console.WriteLine(myPhone.CalcPrice(0.37));

        myPhone.ClearHistory();
        myPhone.DisplayCallHistory();
    }
    static void Main()
    {
        // GSMTest
        GSM[] test = new GSM[3];

        Display testDisplay = new Display(12, 13);
        Battery testBattery = new Battery(BatteryType.LiIon, 10, 10);

        GSM firstPhone = new GSM("test", "test", 12, "Bai Ivan", testBattery, testDisplay);
        test[0] = firstPhone;

        GSM secondPhone = new GSM("SecondTest", "SecondTest", 14, "Moore Name", testBattery, testDisplay);
        test[1] = secondPhone;

        GSM thirdPhone = new GSM("Some test", "Texttt", 1, "Name", testBattery, testDisplay);
        test[2] = thirdPhone;

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

        Console.WriteLine(GSM.Iphone.Model);
        Console.WriteLine(GSM.Iphone.Manufacturer);
        Console.WriteLine(firstPhone.Battery.BatteryModel);

        Console.WriteLine("---------------------------------");
        Console.WriteLine("GSMCallHistoryTest");
        Console.WriteLine("---------------------------------");

        //GSMCallHistoryTest
        GSM myPhone = new GSM("Nokia", "Nokia Corp", 1, "Ivan", testBattery, testDisplay);

        myPhone.AddCall(DateTime.Now, "088888888", 236);
        myPhone.AddCall(DateTime.Now, "077777777", 333);
        myPhone.AddCall(DateTime.Now, "066666666", 123);
        myPhone.AddCall(DateTime.Now, "055555555", 11);
        myPhone.AddCall(DateTime.Now, "044444444", 23);

        myPhone.DisplayCallHistory();

        Console.WriteLine(myPhone.CalcPrice(0.37));

        myPhone.RemoveCallByDuration(333);

        myPhone.DisplayCallHistory();
        Console.WriteLine(myPhone.CalcPrice(0.37));

        myPhone.ClearHistory();
        myPhone.DisplayCallHistory();
    }
Exemplo n.º 10
0
    static void Main()
    {
        //GSM Test
        GSM[] mobilePhoneArray = new GSM[3];

        Display testDisplay = new Display(8, 160);
        Battery testBattery = new Battery(BatteryType.LiIon, 10, 10);

        GSM firstMobile = new GSM("Lumia", "Nokia", 350, "Pesho", testBattery, testDisplay);
        mobilePhoneArray[0] = firstMobile;

        GSM secondMobile = new GSM("One", "HTC", 700, "Toshko", testBattery, testDisplay);
        mobilePhoneArray[1] = secondMobile;

        GSM thirdMobile = new GSM("Galaxy S3", "Samsung", 500, "Ganio", testBattery, testDisplay);
        mobilePhoneArray[2] = secondMobile;

        for (int i = 0; i < mobilePhoneArray.Length; i++)
        {
            Console.WriteLine(mobilePhoneArray[i]);
            Console.WriteLine(new string('=', 17));
            Console.WriteLine();
        }

        Console.WriteLine(GSM.Iphone.Model);
        Console.WriteLine(GSM.Iphone.Manufacturer);
        Console.WriteLine(GSM.Iphone.Price);
        Console.WriteLine();

        //GSM Call History Test
        GSM myPhone = new GSM("Lumia", "Nokia", 459, "Kiro", testBattery, testDisplay);

        myPhone.AddCall(DateTime.Now, "0884647523", 456);
        myPhone.AddCall(DateTime.Now, "0894547579", 320);
        myPhone.AddCall(DateTime.Now, "0875578923", 15);
        myPhone.AddCall(DateTime.Now, "0888987051", 45);
        myPhone.AddCall(DateTime.Now, "0880600700", 32);
        myPhone.AddCall(DateTime.Now, "0875657258", 69);

        myPhone.DisplayCallHistory();

        Console.WriteLine(myPhone.CalcPrice(0.37));

        myPhone.RemoveCallByDuration(456);

        myPhone.DisplayCallHistory();
        Console.WriteLine(myPhone.CalcPrice(0.37));

        myPhone.ClearHistory();
        myPhone.DisplayCallHistory();
    }
Exemplo n.º 11
0
    static void Main()
    {
        // GSMTest
        GSM[] test = new GSM[3];
        Display testDisplay = new Display(5, 65000);
        Battery testBattery = new Battery(BatteryType.LiIon, 15, 20);

        GSM firstPhone = new GSM("StarII", "Samsung", 120, "Pesho", testBattery, testDisplay);
        test[0] = firstPhone;

        Display test2Display = new Display(3, 250);
        Battery test2Battery = new Battery(BatteryType.NiCd, 10, 12);
        GSM secondPhone = new GSM("Desire 300", "HTC", 300, "Ivan", test2Battery, test2Display);
        test[1] = secondPhone;

        Display test3Display = new Display(7, 255000);
        Battery test3Battery = new Battery(BatteryType.NiMH, 5, 6);
        GSM thirdPhone = new GSM("Lumbia 625", "Nokia", 650, "Kalina", test3Battery, test3Display);
        test[2] = thirdPhone;

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

        Console.WriteLine(GSM.Iphone.Model);
        Console.WriteLine(GSM.Iphone.Manufacturer);
        Console.WriteLine(firstPhone.Battery.BatteryModel);
        Console.WriteLine(new string('-',70));
        Console.WriteLine("GSM CALL Histiry Test");
        Console.WriteLine(new string('-', 70));

        //GSM Call History Test
        GSM myPhone = new GSM("IPhone4S", "Apple", 450, "Lili", testBattery, testDisplay);

        myPhone.AddCall(DateTime.Now, "0888665533", 55);
        myPhone.AddCall(DateTime.Now, "0888345678", 512);
        myPhone.AddCall(DateTime.Now, "0888123456", 238);
        myPhone.AddCall(DateTime.Now, "0888987654", 5);
        myPhone.AddCall(DateTime.Now, "0888244668", 105);
        myPhone.AddCall(DateTime.Now, "0888133557", 89);
        myPhone.AddCall(DateTime.Now, "0888435465", 72);
        myPhone.DisplayCallHistory();
        Console.WriteLine(myPhone.CalcPrice(0.37));
        myPhone.RemoveCallByDuration(105);
        myPhone.DisplayCallHistory();
        Console.WriteLine(myPhone.CalcPrice(0.37));
        myPhone.ClearHistory();
        myPhone.DisplayCallHistory();
    }
Exemplo n.º 12
0
 static void Main()
 {
     System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
     GSM gsm = new GSM("Galaxy S3", "Samsung");
     gsm.AddCall(846022, 150);
     gsm.AddCall(35956, 132);
     gsm.PrintCalls();
     Console.WriteLine("-------------");
     gsm.RemoveCall(35956);
     gsm.PrintCalls();
     Console.WriteLine("-------------");
     gsm.AddCall(654213, 32);
     gsm.ClearHistory();
     gsm.PrintCalls();
 }
Exemplo n.º 13
0
    static void Main()
    {
        GSM phone = new GSM("Moto X", "Motorola");

        phone.AddCall(DateTime.Now, "0899789987", 500);
        phone.AddCall(new DateTime(2013, 2, 16), "0899233987", 350);
        phone.AddCall(new DateTime(2013, 2, 12), "0899123456", 58);
        phone.AddCall(new DateTime(2013, 2, 13), "0899123456", 58);
        phone.AddCall(new DateTime(2013, 2, 14), "0899123456", 69);
        phone.AddCall(new DateTime(2013, 2, 14), "0899123456", 69);
        Console.WriteLine(phone.ToString());
        phone.ShowCallHistory();
        phone.CalcPrice(0.37M);
        phone.RemoveLongestCall();
        phone.CalcPrice(0.37M);
        phone.ClearHistory();
        phone.ShowCallHistory();
    }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            //Create an instance of the GSM class.
            Battery phoneBattery = new Battery("NiCd", 30.6, 5.6);
            Display phoneDisplay = new Display(5.0, 16000000);
            GSM phone = new GSM("Galaxy Note", "Samsung", 866, "Goran Bregovic", phoneBattery, phoneDisplay);

            //Add few calls.
            DateTime dateAndTime = new DateTime(2013, 3, 5, 11, 59, 59);
            Call callOne = new Call(dateAndTime, "0888455455", 110);
            Call callTwo = new Call(dateAndTime, "0899455455", 50);
            Call callThree = new Call(dateAndTime, "0886455455", 230);

            phone.AddCall(callOne);
            phone.AddCall(callTwo);
            phone.AddCall(callThree);
            //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.
            Console.WriteLine(phone.CallHistoryToString);
            double price = phone.CalculatePrice(0.37);
            Console.WriteLine("The price for the whole history is {0}", price);

            //Remove the longest call from the history and calculate the total price again.
            uint maxDuritation = uint.MinValue;
            Call callToRemove = new Call(dateAndTime, "0886455455", 0);
            for (int i = 0; i < phone.CallHistory.Count; i++)
            {
                if (phone.CallHistory[i].Duritation > maxDuritation)
                {
                    maxDuritation = phone.CallHistory[i].Duritation;
                    callToRemove = phone.CallHistory[i];
                }
            }
            phone.DeleteCall(callToRemove);
            price = phone.CalculatePrice(0.37);
            Console.WriteLine("The new price after we removed the longest call is {0}", price);

            //Finally clear the call history and print it.
            Console.WriteLine();
            Console.WriteLine("Clearing History...");
            phone.ClearHistory();
            Console.WriteLine("Call History: {0}", phone.CallHistoryToString);
        }
    static void Main()
    {
        // Initialise an object to the already set static property
        GSM currentGSM = GSM.IPhone4S;

        // Add some calls
        currentGSM.AddCall(DateTime.Now, "12315123", 43);
        currentGSM.AddCall(DateTime.Now, "123156341", 27);
        currentGSM.AddCall(DateTime.Now, "080823874", 132);

        // Get the longest duration call and display details about each call
        int longestDurationIndex = int.MinValue;
        int longestDuration      = int.MinValue;

        for (int i = 0; i < currentGSM.CallHistory.Count; i++)
        {
            Console.WriteLine(currentGSM.CallHistory[i].ToString());
            Console.WriteLine();

            if (currentGSM.CallHistory[i].Duration > longestDuration)
            {
                longestDurationIndex = i;
                longestDuration      = currentGSM.CallHistory[i].Duration;
            }
        }

        // Calculate total call history price
        Console.WriteLine("{0:0.00}", currentGSM.CalculateTotalCallPrice(0.37m));

        // Remove the longest duration call and recalculate the call history price
        currentGSM.DeleteCall(longestDurationIndex);

        Console.WriteLine("{0:0.00}", currentGSM.CalculateTotalCallPrice(0.37m));

        // Clear the call history
        currentGSM.ClearHistory();

        foreach (var call in currentGSM.CallHistory)
        {
            Console.WriteLine(call.ToString());
        }
    }
        public static void CallHistory()
        {
            GSM callTest = new GSM("3310", "Nokia", 10, "Stamat", new Battery(BatteryType.Unknown, 999999999, 99999999), new Display(1, 2));

            callTest.AddCall(DateTime.Now, "0888888888", 360);
            callTest.AddCall(new DateTime(2016, 6, 6, 12, 35, 10), "0877777777", 956);
            callTest.AddCall(new DateTime(2016, 7, 6, 20, 10, 32), "0877777777", 1082);

            Console.WriteLine("Call history:");
            Console.WriteLine(callTest.CallHistory);
            Console.WriteLine("Price for calls:");
            Console.WriteLine("${0:F2}", callTest.GetPrice());

            callTest.RemoveLongestCall();
            Console.WriteLine("Price after removed longest call:");
            Console.WriteLine("${0:F2}", callTest.GetPrice());

            callTest.ClearHistory();
            Console.WriteLine(callTest.CallHistory);
        }
Exemplo n.º 17
0
        public static void CallHistory()
        {
            GSM callTest = new GSM("Galaxy 5", "Samsung", 10, "Yordan Yordanov", new Battery(BatteryType.Unknown, 999999999, 99999999), new Display(1, 2));

            callTest.AddCall(DateTime.Now, "+359888111222", 360);
            callTest.AddCall(new DateTime(2016, 5, 30, 07, 10, 14), "+359888123456", 601);
            callTest.AddCall(new DateTime(2016, 5, 31, 15, 10, 18), "+359888123456", 128);

            Console.WriteLine("Call history:");
            Console.WriteLine(callTest.CallHistory);
            Console.WriteLine("Price for calls:");
            Console.WriteLine("${0:F2}", callTest.GetPrice());

            callTest.RemoveLongestCall();
            Console.WriteLine("Price after removed longest call:");
            Console.WriteLine("${0:F2}", callTest.GetPrice());

            callTest.ClearHistory();
            Console.WriteLine(callTest.CallHistory);
        }
Exemplo n.º 18
0
 static void Main()
 {
     GSM[] tests = new GSM[3];
     GSM cellPhone1 = new GSM("Desire X", "HTC", "HTC Store", 499.99M);
     tests[0] = cellPhone1;
     GSM cellPhone2 = new GSM("Lumia 810", "Nokia");
     cellPhone2.Price = 499.99M;
     cellPhone2.Owner = "OVI Store";
     cellPhone2.battery.Type = BatteryType.Li_Ion;
     tests[1] = cellPhone2;
     GSM cellPhone3 = GSM.iPhone;
     tests[2] = cellPhone3;
     foreach (var item in tests)
     {
         Console.WriteLine(item);
     }
     cellPhone1.AddCall(DateTime.Now, "0897789987", 230);
     cellPhone1.CalcPrice(0.32M);
     cellPhone1.RemoveCall();
     cellPhone1.ClearHistory();
 }
    static void Main()
    {
        // just some sample tests

        GSM tel = new GSM("Nokia", "gosho tupoto", owner: "Pesho");
        tel.AddCall("0885032502", new DateTime(2003, 2, 1), new TimeSpan(0, 10, 15));
        tel.AddCall("0883456782", new DateTime(2003, 2, 1), new TimeSpan(0, 20, 15));
        tel.AddCall("+359885032548", new DateTime(2003, 2, 1), new TimeSpan(0, 10, 15));
        tel.AddCall("+359885032576", new DateTime(2003, 2, 1), new TimeSpan(0, 15, 15));
        Console.WriteLine(tel.GetCost(0.37));
        tel.RemoveCall();
        tel.PrintHistory();
        Console.WriteLine(tel.GetCost(0.37));
        tel.ClearHistory();
        tel.PrintHistory();
        Console.WriteLine(tel + "\n\n\n");

        // IPhone test

        Console.WriteLine(GSM.IPhone4S);
    }
    static void Main()
    {
        // just some sample tests

        GSM tel = new GSM("Nokia", "gosho tupoto", owner: "Pesho");

        tel.AddCall("0885032502", new DateTime(2003, 2, 1), new TimeSpan(0, 10, 15));
        tel.AddCall("0883456782", new DateTime(2003, 2, 1), new TimeSpan(0, 20, 15));
        tel.AddCall("+359885032548", new DateTime(2003, 2, 1), new TimeSpan(0, 10, 15));
        tel.AddCall("+359885032576", new DateTime(2003, 2, 1), new TimeSpan(0, 15, 15));
        Console.WriteLine(tel.GetCost(0.37));
        tel.RemoveCall();
        tel.PrintHistory();
        Console.WriteLine(tel.GetCost(0.37));
        tel.ClearHistory();
        tel.PrintHistory();
        Console.WriteLine(tel + "\n\n\n");

        // IPhone test

        Console.WriteLine(GSM.IPhone4S);
    }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            GSM NokiaGSM = new GSM("N-30", "Nokia", 180m, new Person("Gogo"), new Battery("825L", 123, 100, BatteryType.LiIon), new Display(15, 1024));

            NokiaGSM.AddCall(new Call(DateTime.Now, "088888888", 156));
            NokiaGSM.AddCall(new Call(DateTime.Now.AddDays(3), "0888888899", 12));
            NokiaGSM.AddCall(new Call(DateTime.Now.AddHours(1), "0888888344", 100));
            NokiaGSM.AddCall(new Call(DateTime.Now.AddHours(56), "088883443", 1500));

            decimal maxDuration             = NokiaGSM.CallHistory[0].DurationInSeconds;
            int     positionMaxDurationCall = 0;

            for (int i = 0; i < NokiaGSM.CallHistory.Count; i++)
            {
                Console.WriteLine("{0} call {1}", i + 1, NokiaGSM.CallHistory[i]);
                Console.WriteLine();
                if (NokiaGSM.CallHistory[i].DurationInSeconds > maxDuration)
                {
                    maxDuration             = NokiaGSM.CallHistory[i].DurationInSeconds;
                    positionMaxDurationCall = i;
                }
            }

            Console.WriteLine(new string('-', 50));
            Console.Write("The total price of your {0} calls is:  ", NokiaGSM.CallHistory.Count);

            Console.WriteLine(NokiaGSM.CalculatePrice(0.37m));

            NokiaGSM.RemoveCall(NokiaGSM.CallHistory[positionMaxDurationCall]);

            Console.Write("The total price of your {0} calls without the longest one is:  ", NokiaGSM.CallHistory.Count);
            Console.WriteLine(NokiaGSM.CalculatePrice(0.37m));

            NokiaGSM.ClearHistory(NokiaGSM.CallHistory);
            Console.Write("After clearing the history, there are {0} calls.", NokiaGSM.CallHistory.Count);

            Console.WriteLine();
        }
Exemplo n.º 22
0
 static void Main()
 {
     //GSMTest Display the information about the GSMs in the array.
     GSM[] myGSMs = new GSM[5];
     GSM phone;
     for (int i = 0; i < myGSMs.Length; i++)
     {
         phone = new GSM("model "+i,"manufact");
         myGSMs[i]=phone;
         Console.WriteLine(myGSMs[i].ToString());
     }
     //Display the information about the static property IPhone4S
     GSM.iPhone4s.ToString();
     //Add few calls.
     phone = new GSM("jhgfhjg540", "manufact");
     Random rand = new Random();
     int phoneForDelete=0;
     for (int i = 0; i < 5; i++)
     {
         phone.AddCall(DateTime.Now, rand.Next(100000, 9999999).ToString(), rand.Next(1, 250));
         if (i==2)
         {
             phoneForDelete=rand.Next(100000, 9999999);
             phone.AddCall(DateTime.Now, phoneForDelete.ToString(), rand.Next(1, 250));
             i++;
         }
     }
     //Display the information about the calls.
     phone.DisplayCallHistory();
     //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
     Console.WriteLine("Price: "+phone.CalcPrice(0.37));
     //Remove the longest call from the history and calculate the total price again.
     phone.DeleteCall(phoneForDelete.ToString());
     phone.DisplayCallHistory();
     //Finally clear the call history and print it
     phone.ClearHistory();
     phone.DisplayCallHistory();
 }
Exemplo n.º 23
0
    static void Main(string[] args)
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        GSM NokiaGSM = new GSM("Nokia", "NK", 180, "Gogo", new Battery("825L", 123, 100, BatteryType.LiIon), new Display(15, 1024));

        NokiaGSM.AddCall(new Call(DateTime.Now, "088888888", 156));
        NokiaGSM.AddCall(new Call(DateTime.Now.AddDays(3), "0888888899", 12));
        NokiaGSM.AddCall(new Call(DateTime.Now.AddHours(1), "0888888344", 100));
        NokiaGSM.AddCall(new Call(DateTime.Now.AddHours(56), "088883443", 1500));

        decimal maxDuration = NokiaGSM.CallHistory[0].DurationInSeconds;
        int positionMaxDurationCall = 0;

        for (int i = 0; i < NokiaGSM.CallHistory.Count; i++)
        {
            Console.WriteLine("{0} call {1}",i+1, NokiaGSM.CallHistory[i]);
            Console.WriteLine();
            if (NokiaGSM.CallHistory[i].DurationInSeconds>maxDuration)
            {
                maxDuration = NokiaGSM.CallHistory[i].DurationInSeconds;
                positionMaxDurationCall = i;
            }
        }
        Console.WriteLine(new string('-', 50));
        Console.Write("The total price of your {0} calls is:  ", NokiaGSM.CallHistory.Count);

        Console.WriteLine(NokiaGSM.CalculatePriceAllCalls(NokiaGSM.CallHistory, 0.37m));

        NokiaGSM.RemoveCall(NokiaGSM.CallHistory[positionMaxDurationCall]);

        Console.Write("The total price of your {0} calls without the longest one is:  ", NokiaGSM.CallHistory.Count);
        Console.WriteLine(NokiaGSM.CalculatePriceAllCalls(NokiaGSM.CallHistory, 0.37m));

        NokiaGSM.ClearHistory(NokiaGSM.CallHistory);
        Console.Write("After clearing the history, there are {0} calls.", NokiaGSM.CallHistory.Count);

        Console.WriteLine();
    }
        static void Main(string[] args)
        {
            GSM gsm = new GSM("HTC One X", "HTC", 799.00, "Vankata", 4.7, 16000000);
            gsm.AddCall(new Call(DateTime.Parse("12.09.2013 15:00:12"), "+359888333555", 122)); // Price for the call = 1.11
            gsm.AddCall(new Call(DateTime.Parse("20.9.2013 17:52:51"), "+359889121223", 54)); // Price for the call = 0.37
            gsm.AddCall(new Call(DateTime.Parse("25.09.2013 8:10:22"), "+359789444222", 180)); // Price for the call = 1.11

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(gsm.CallsInformation());

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Total price of the calls = {0}", gsm.TotalPriceOfCalls(0.37)); // Total price = 2.59

            int maxDuration = -1;
            int indexMaxDuration = -1;

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

            gsm.DeleteCall(indexMaxDuration);

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("Total price of the calls = {0}", gsm.TotalPriceOfCalls(0.37)); // Total price = 1.48

            gsm.ClearHistory();

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Total price of the calls = {0}", gsm.TotalPriceOfCalls(0.37)); // Total price = 0

            Console.WriteLine();
        }
Exemplo n.º 25
0
    public static void RunTest()
    {
        GSM myPhone = new GSM("HTC Desire", "HTC", 550, "Pesho", new Battery(BatteryType.LiIon), new Display(4, 250000));

        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(5), "0887776987");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(8), "0897556644");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(15), "0887441100");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(23), "0885001122");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(4), "0896559988");

        Console.WriteLine(myPhone);
        Console.WriteLine("-----------Call History-----------");
        foreach (Call call in myPhone.CallHistory)
        {
            Console.WriteLine(call);
        }

        Console.WriteLine("Total price of all calls: ${0:F2}", myPhone.TotalCallsCost(0.37));
        myPhone.DeleteLongestCall();
        Console.WriteLine("After the remove of the longest call the total price is: ${0:F2}", myPhone.TotalCallsCost(0.37));
        Console.WriteLine();

        myPhone.ClearHistory();
        Console.WriteLine("-----------Cleared Call History-----------");
        if (myPhone.CallHistory.Count == 0)
        {
            Console.WriteLine("There are no Recorded Calls in the History!");
        }
        else
        {
            foreach (Call call in myPhone.CallHistory)
            {
                Console.WriteLine(call);
            }
        }
    }
Exemplo n.º 26
0
        public static void TestCallHistory()
        {
            // Add a few calls
            gsm.AddCall(new Call {
                Date = DateTime.Now, DialedPhone = "+359889555444", Duration = 300
            });
            gsm.AddCall(new Call {
                Date = DateTime.Now, DialedPhone = "+35912345678", Duration = 125
            });
            gsm.AddCall(new Call {
                Date = DateTime.Now, DialedPhone = "+359666666", Duration = 567
            });
            gsm.AddCall(new Call {
                Date = DateTime.Now, DialedPhone = "+000000000", Duration = 58
            });

            // Display information about the calls
            PrintCallHistory();

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

            // Remove the longest call from the history and calculate the total price again.
            var longestCall = gsm.CallHistory.OrderByDescending(c => c.Duration).FirstOrDefault();

            Console.WriteLine($"\nRemoving longest call (ID = {longestCall.Id})\n");
            gsm.CallHistory.Remove(longestCall);

            PrintCallHistory();
            CalculatePrice();

            // Finally clear the call history and print it.
            Console.WriteLine("Clearing call history.");
            gsm.ClearHistory();
            PrintCallHistory();
        }
Exemplo n.º 27
0
    static void Main()
    {
        GSM firstGSM = new GSM();

        // USER INPUT

        //Console.WriteLine("Enter phone model: ");
        //firstGSM.Model = Console.ReadLine();
        //Console.WriteLine("Enter manufacturer: ");
        //firstGSM.Manufacturer = Console.ReadLine();
        //Console.WriteLine("Enter price: ");
        //firstGSM.Price = int.Parse(Console.ReadLine());
        //Console.WriteLine("Enter owner: ");
        //firstGSM.Owner = Console.ReadLine();

        //Console.WriteLine("Enter battery model between Li-Ion,NiMH,NiCD(0-2): ");
        //firstGSM.Battery.Model = (BatteryType)int.Parse(Console.ReadLine());
        //Console.WriteLine("Enter hours idle: ");
        //firstGSM.Battery.HoursIdle = double.Parse(Console.ReadLine());
        //Console.WriteLine("Enter hours talked: ");
        //firstGSM.Battery.HoursTalked = double.Parse(Console.ReadLine());

        //Console.WriteLine("Enter display size: ");
        //firstGSM.Display.Size = uint.Parse(Console.ReadLine());
        //Console.WriteLine("Enter display colours: ");
        //firstGSM.Display.Colours = uint.Parse(Console.ReadLine());

        //AUTO INPUT

        firstGSM.Model               = "Galaxy S";
        firstGSM.Manufacturer        = "Samsung";
        firstGSM.Price               = 899;
        firstGSM.Owner               = "The Owner";
        firstGSM.Battery.Model       = BatteryType.NiCD;
        firstGSM.Battery.HoursIdle   = 216.5;
        firstGSM.Battery.HoursTalked = 15.5;
        firstGSM.Display.Size        = 11;
        firstGSM.Display.Colours     = 65356;

        firstGSM.Print();
        firstGSM.Battery.Print();
        firstGSM.Display.Print();

        GSM newGSM = new GSM("IPhone", "Apple");

        newGSM.Print();
        newGSM.Battery.Print();
        newGSM.Display.Print();

        GSM thirdGSM = new GSM("Phone", "Manufact", 106, "Over");

        thirdGSM.Print();


        //Create an array of few instances of the GSM class
        GSM[] myGSM = new GSM[3];

        myGSM[0] = new GSM("Galaxy S2", "Samsung", 750, "Nikolai");
        myGSM[1] = new GSM("3110", "Nokia", 10, "Nikolai");
        myGSM[2] = new GSM("N70", "Nokia", 300, "Nikolai");

        //Display the information about the GSMs in the array
        for (int i = 0; i < myGSM.Length; i++)
        {
            myGSM[i].Print();
        }
        Console.WriteLine();

        //Display the information about the static property IPhone4S.
        GSM.IPhone4S.Print();

        //Assume the price per minute is fixed and is provided as a parameter.
        //Assuming that the price per minute is 0.37
        double pricePerMin = 0.37;

        //Create an instance of the GSM class.
        GSM lastGSM = new GSM("Xperia", "Nokia", 800, "Pesho");

        //Add few calls.
        lastGSM.AddCall("08955454521", 300);
        lastGSM.AddCall("25665663663", 165);
        lastGSM.AddCall("252689657954", 214);

        List <Call> history = lastGSM.CallHistory;

        //Display the information about the calls.
        foreach (var call in history)
        {
            call.PrintCall();
            Console.WriteLine();
        }

        //Calculate and print the total price of the calls in the history.
        Console.WriteLine("The price for the calls is : {0}", lastGSM.CalcPrice(pricePerMin));

        //Select the longest call
        int  maxDurationIndex = 0;
        uint maxDuration      = 0;

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

        //Remove the longest call from the history
        lastGSM.DeleteCall(maxDurationIndex);

        //Calculate the total price again.
        Console.WriteLine("The price for the calls is : {0}", lastGSM.CalcPrice(pricePerMin));

        //Finally clear the call history
        lastGSM.ClearHistory();

        //and print it.
        foreach (var call in history)
        {
            call.PrintCall();
            Console.WriteLine();
        }
    }
Exemplo n.º 28
0
    public static void Main()
    {
        //Creating the instance of GSM.
        Battery litiumBattery = new Battery("Normal", 123, 20.5, BatteryType.LiIon);
        Display big           = new Display(8.4, 3000);
        GSM     myPhone       = new GSM("W595", "Sony - Erikson", 678, "Cecilia", litiumBattery, big);

        //Adding few calls.
        Call[] calls = new Call[4];
        calls[0] = new Call(DateTime.Today, DateTime.Now, "0888123456", 123);
        calls[1] = new Call(DateTime.Today, DateTime.Now, "0877123456", 45);
        calls[2] = new Call(DateTime.Today, DateTime.Now, "0899123456", 540);
        calls[3] = new Call(DateTime.Today, DateTime.Now, "0789123456", 18);
        for (int i = 0; i < calls.Length; i++)
        {
            myPhone.AddHistory(calls[i]);
        }

        //Display calls information.
        foreach (var item in myPhone.callHistory)
        {
            Console.WriteLine("Date and time: {0}, Dialed phone: {1}, Duration: {2} seconds", item.Time, item.DialedPhone, item.Duration);
            Console.WriteLine();
        }

        //Print total price.
        Console.WriteLine();
        Console.WriteLine("The total price of the calls is {0:f2}", myPhone.CalculateTotalPrice(0.37));

        //Remove longest call and calculate price again.
        int    longestCallIndex = 0;
        double longestDuration  = 0.0;

        for (int i = 0; i < myPhone.callHistory.Count; i++)
        {
            if (myPhone.callHistory[i].Duration > longestDuration)
            {
                longestCallIndex = i;
                longestDuration  = myPhone.callHistory[i].Duration;
            }
        }
        myPhone.DeleteHistory(longestCallIndex);
        Console.WriteLine();
        Console.WriteLine("The total price of the calls is {0:f2}", myPhone.CalculateTotalPrice(0.37));

        //Clear history and print it.
        myPhone.ClearHistory();
        Console.WriteLine();
        if (myPhone.callHistory.Count > 0)
        {
            foreach (var item in myPhone.callHistory)
            {
                Console.WriteLine("Date and time: {0}, Dialed phone: {1}, Duration: {2} seconds", item.Time, item.DialedPhone, item.Duration);
                Console.WriteLine();
            }
        }
        else
        {
            Console.WriteLine("Empty");
        }
    }
Exemplo n.º 29
0
    static void Main()
    {
        GSM firstGSM = new GSM();

        // USER INPUT

        //Console.WriteLine("Enter phone model: ");
        //firstGSM.Model = Console.ReadLine();
        //Console.WriteLine("Enter manufacturer: ");
        //firstGSM.Manufacturer = Console.ReadLine();
        //Console.WriteLine("Enter price: ");
        //firstGSM.Price = int.Parse(Console.ReadLine());
        //Console.WriteLine("Enter owner: ");
        //firstGSM.Owner = Console.ReadLine();

        //Console.WriteLine("Enter battery model between Li-Ion,NiMH,NiCD(0-2): ");
        //firstGSM.Battery.Model = (BatteryType)int.Parse(Console.ReadLine());
        //Console.WriteLine("Enter hours idle: ");
        //firstGSM.Battery.HoursIdle = double.Parse(Console.ReadLine());
        //Console.WriteLine("Enter hours talked: ");
        //firstGSM.Battery.HoursTalked = double.Parse(Console.ReadLine());

        //Console.WriteLine("Enter display size: ");
        //firstGSM.Display.Size = uint.Parse(Console.ReadLine());
        //Console.WriteLine("Enter display colours: ");
        //firstGSM.Display.Colours = uint.Parse(Console.ReadLine());

        //AUTO INPUT

        firstGSM.Model = "Galaxy S";
        firstGSM.Manufacturer = "Samsung";
        firstGSM.Price = 899;
        firstGSM.Owner = "The Owner";
        firstGSM.Battery.Model = BatteryType.NiCD;
        firstGSM.Battery.HoursIdle = 216.5;
        firstGSM.Battery.HoursTalked = 15.5;
        firstGSM.Display.Size = 11;
        firstGSM.Display.Colours = 65356;

        firstGSM.Print();
        firstGSM.Battery.Print();
        firstGSM.Display.Print();

        GSM newGSM = new GSM("IPhone","Apple");

        newGSM.Print();
        newGSM.Battery.Print();
        newGSM.Display.Print();

        GSM thirdGSM = new GSM("Phone", "Manufact", 106, "Over");
        thirdGSM.Print();

        //Create an array of few instances of the GSM class
        GSM[] myGSM = new GSM[3];

        myGSM[0] = new GSM("Galaxy S2", "Samsung", 750, "Nikolai");
        myGSM[1] = new GSM("3110", "Nokia", 10, "Nikolai");
        myGSM[2] = new GSM("N70", "Nokia", 300, "Nikolai");

        //Display the information about the GSMs in the array
        for (int i = 0; i < myGSM.Length; i++)
        {
            myGSM[i].Print();
        }
        Console.WriteLine();

        //Display the information about the static property IPhone4S.
        GSM.IPhone4S.Print();

        //Assume the price per minute is fixed and is provided as a parameter.
        //Assuming that the price per minute is 0.37
        double pricePerMin = 0.37;

        //Create an instance of the GSM class.
        GSM lastGSM = new GSM("Xperia", "Nokia", 800, "Pesho");

        //Add few calls.
        lastGSM.AddCall("08955454521", 300);
        lastGSM.AddCall("25665663663", 165);
        lastGSM.AddCall("252689657954", 214);

        List<Call> history = lastGSM.CallHistory;

        //Display the information about the calls.
        foreach (var call in history)
        {
            call.PrintCall();
            Console.WriteLine();
        }

        //Calculate and print the total price of the calls in the history.
        Console.WriteLine("The price for the calls is : {0}", lastGSM.CalcPrice(pricePerMin));

        //Select the longest call
        int maxDurationIndex = 0;
        uint maxDuration = 0;
        for (int i = 0; i < history.Count; i++)
        {
            if (history[i].Duration > maxDuration)
            {
                maxDurationIndex = i;
                maxDuration = history[i].Duration;
            }
        }

        //Remove the longest call from the history
        lastGSM.DeleteCall(maxDurationIndex);

        //Calculate the total price again.
        Console.WriteLine("The price for the calls is : {0}", lastGSM.CalcPrice(pricePerMin));

        //Finally clear the call history
        lastGSM.ClearHistory();

        //and print it.
        foreach (var call in history)
        {
            call.PrintCall();
            Console.WriteLine();
        }
    }
Exemplo n.º 30
0
    public static void Main()
    {
        //Creating the instance of GSM.
        Battery litiumBattery = new Battery("Normal", 123, 20.5, BatteryType.LiIon);
        Display big = new Display(8.4, 3000);
        GSM myPhone = new GSM("W595", "Sony - Erikson", 678, "Cecilia", litiumBattery, big);

        //Adding few calls.
        Call[] calls = new Call[4];
        calls[0] = new Call(DateTime.Today, DateTime.Now, "0888123456", 123);
        calls[1] = new Call(DateTime.Today, DateTime.Now, "0877123456", 45);
        calls[2] = new Call(DateTime.Today, DateTime.Now, "0899123456", 540);
        calls[3] = new Call(DateTime.Today, DateTime.Now, "0789123456", 18);
        for (int i = 0; i < calls.Length; i++)
        {
            myPhone.AddHistory(calls[i]);
        }

        //Display calls information.
        foreach (var item in myPhone.callHistory)
        {
            Console.WriteLine("Date and time: {0}, Dialed phone: {1}, Duration: {2} seconds", item.Time, item.DialedPhone, item.Duration);
            Console.WriteLine();
        }

        //Print total price.
        Console.WriteLine();
        Console.WriteLine("The total price of the calls is {0:f2}", myPhone.CalculateTotalPrice(0.37));

        //Remove longest call and calculate price again.
        int longestCallIndex = 0;
        double longestDuration = 0.0;
        for (int i = 0; i < myPhone.callHistory.Count; i++)
        {
            if (myPhone.callHistory[i].Duration > longestDuration)
            {
                longestCallIndex = i;
                longestDuration = myPhone.callHistory[i].Duration;
            }
        }
        myPhone.DeleteHistory(longestCallIndex);
        Console.WriteLine();
        Console.WriteLine("The total price of the calls is {0:f2}", myPhone.CalculateTotalPrice(0.37));

        //Clear history and print it.
        myPhone.ClearHistory();
        Console.WriteLine();
        if (myPhone.callHistory.Count > 0)
        {
            foreach (var item in myPhone.callHistory)
            {
                Console.WriteLine("Date and time: {0}, Dialed phone: {1}, Duration: {2} seconds", item.Time, item.DialedPhone, item.Duration);
                Console.WriteLine();
            }
        }
        else
        {
            Console.WriteLine("Empty");
        }

    }
Exemplo n.º 31
0
 public static void Check_Clear_Call_History()
 {
     testInstance.ClearHistory();
     testInstance.PrintHistory();
 }
Exemplo n.º 32
0
    static void Main()
    {
        GSM[] gsmArray = { 
                             new GSM("S3", "Galaxy", 710M, "Reni", new Battery("A12", 20, 5, BatteryType.LiIon), new Display(4.8, 50000)),
                             new GSM("5", "Nexus", 610M, "Stasko", new Battery("A13", 19, 6, BatteryType.NiCd), new Display(5, 40000)),
                         };

        foreach (var gsm in gsmArray)
        {
            Console.WriteLine(gsm.ToString());
            Console.WriteLine(new string('-', 50));
        }

        Console.WriteLine("Static property: {0}", GSM.IPhone4S);

        GSM myGSM = new GSM("Xperia", "Sony", 510M, "Didi", new Battery("A14", 15, 7, BatteryType.NiMH), new Display(4.9, 45000));


        List<Call> callHistory = new List<Call>
                            {
                               new Call(new DateTime(2015, 03, 18), new Time(23, 22, 56), "0888123456", 360),
                               new Call(new DateTime(2015, 02, 19), new Time(13, 19, 25), "0888124556", 520),
                               new Call(new DateTime(2015, 01, 15), new Time(11, 10, 20), "0888124106", 800)
                            };

        //add calls to call history list
        foreach (var call in callHistory)
        {
            myGSM.AddCall(call);
        }

        Console.WriteLine(myGSM.ToString());
        myGSM.CallHistory.Add(new Call(new DateTime(2015, 01, 15), new Time(11, 10, 20), "0888124106", 800));
        //print call history
        myGSM.PrintCallHistory();

        //calculate total price and print it
        decimal totalPrice = myGSM.CallPrice(myGSM.CallHistory, 0.37M);
        Console.WriteLine("Total call's price: {0}", totalPrice);

        //remove the longest call from the history 
        Call longestCall = new Call();
        foreach (var call in callHistory)
        {
            if (longestCall.Duration <= call.Duration)
            {
                longestCall = call;
            }
        }

        //delete longest call
        myGSM.DeleteCall(longestCall);
        myGSM.PrintCallHistory();

        //calculate the total price again
        totalPrice = myGSM.CallPrice(myGSM.CallHistory, 0.37M);
        Console.WriteLine("Total call's price: {0}", totalPrice);

        //clear the call history and print it.
        myGSM.ClearHistory();
        myGSM.PrintCallHistory();
    }
Exemplo n.º 33
0
    static void Main()
    {
        GSM[] gsmArray =
        {
            new GSM("S3", "Galaxy", 710M, "Reni",   new Battery("A12", 20, 5, BatteryType.LiIon), new Display(4.8, 50000)),
            new GSM("5",  "Nexus",  610M, "Stasko", new Battery("A13", 19, 6, BatteryType.NiCd),  new Display(5,   40000)),
        };

        foreach (var gsm in gsmArray)
        {
            Console.WriteLine(gsm.ToString());
            Console.WriteLine(new string('-', 50));
        }

        Console.WriteLine("Static property: {0}", GSM.IPhone4S);

        GSM myGSM = new GSM("Xperia", "Sony", 510M, "Didi", new Battery("A14", 15, 7, BatteryType.NiMH), new Display(4.9, 45000));


        List <Call> callHistory = new List <Call>
        {
            new Call(new DateTime(2015, 03, 18), new Time(23, 22, 56), "0888123456", 360),
            new Call(new DateTime(2015, 02, 19), new Time(13, 19, 25), "0888124556", 520),
            new Call(new DateTime(2015, 01, 15), new Time(11, 10, 20), "0888124106", 800)
        };

        //add calls to call history list
        foreach (var call in callHistory)
        {
            myGSM.AddCall(call);
        }

        Console.WriteLine(myGSM.ToString());
        myGSM.CallHistory.Add(new Call(new DateTime(2015, 01, 15), new Time(11, 10, 20), "0888124106", 800));
        //print call history
        myGSM.PrintCallHistory();

        //calculate total price and print it
        decimal totalPrice = myGSM.CallPrice(myGSM.CallHistory, 0.37M);

        Console.WriteLine("Total call's price: {0}", totalPrice);

        //remove the longest call from the history
        Call longestCall = new Call();

        foreach (var call in callHistory)
        {
            if (longestCall.Duration <= call.Duration)
            {
                longestCall = call;
            }
        }

        //delete longest call
        myGSM.DeleteCall(longestCall);
        myGSM.PrintCallHistory();

        //calculate the total price again
        totalPrice = myGSM.CallPrice(myGSM.CallHistory, 0.37M);
        Console.WriteLine("Total call's price: {0}", totalPrice);

        //clear the call history and print it.
        myGSM.ClearHistory();
        myGSM.PrintCallHistory();
    }