Exemple #1
0
        static void Main()
        {
            Gsm  myPhone       = new Gsm("Galaxy", "Samsung");
            Call newCallFirst  = new Call("0888123456", 15);
            Call newCallSecond = new Call("0888123456", 20);
            Call newCallThird  = new Call("0888123456", 30);

            // add calls information
            myPhone.AddCall(newCallFirst);
            myPhone.AddCall(newCallSecond);
            myPhone.AddCall(newCallThird);
            PrintCallHistory(myPhone.GetCallHistory());//print call history
            //print total Price of the calls
            Console.WriteLine("Total Price of the calls is: {0}", myPhone.CalculateTotalPrice(0.37f));

            int longest   = 0;
            int index     = 0;
            int lastIndex = 0;

            foreach (var item in myPhone.GetCallHistory())
            {
                if (item.Duration > longest)
                {
                    longest   = item.Duration;
                    lastIndex = index;
                }
                index++;
            }
            myPhone.DeleteCall(lastIndex);
            Console.WriteLine("Total Price of the calls is: {0}", myPhone.CalculateTotalPrice(0.37f));
            myPhone.ClearCallHistory();
            PrintCallHistory(myPhone.GetCallHistory());
        }
Exemple #2
0
        static void TestGsm()
        {
            Gsm[]    gsmArr        = new Gsm[5];
            string[] models        = { "Nokia", "Samsung", "HTC", "Iphone", "Sony" };
            int[]    prices        = { 100, 300, 500, 600, 900 };
            string[] owners        = { "Martin", "Alex", "Antonela", "Ivan", "Spas" };
            string[] manifacturers = { "China", "BG", "Japan", "USA", "Tailand" };

            for (int i = 0; i < gsmArr.Length; i++)
            {
                gsmArr[i] = new Gsm(models[i], manifacturers[i], prices[i], owners[i]);
                Console.WriteLine("Diplay all information:");
                Console.WriteLine(gsmArr[i].ToString());
            }
            Console.WriteLine(Gsm.CreateIphone());
        }
Exemple #3
0
 public static Gsm CreateIphone()
 {
     iPhone4S = new Gsm("Iphone 4S", "Apple");
     return(iPhone4S);
 }