Exemple #1
1
        static void Main()
        {
            GSM firstPhone = new GSM("HTC 10", "HTC Corporation");
            GSM secondPhone = new GSM("Y6", "Huawei", "Pesho");
            GSM thirdPhone = new GSM("Nexus 5X", "LG", 1050.99, "Ivan", new Battery("abc", 24, 35), new Display(4, 255));

            //Create an array of few instances of the GSM class.
            GSM[] gsmCollection = { firstPhone, secondPhone, thirdPhone };

            //Display the information about the GSMs in the array.
            foreach (var phone in gsmCollection)
            {
                Console.WriteLine(phone);
                Console.WriteLine();
            }

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

            //Create an instance of the GSM class.
            GSM phoneOne = new GSM("Galaxy S4", "Samsung", 450.99, "M", new Battery("LiIon", 100), new Display(5.0, 16));

            //Add few calls.

            Console.WriteLine("Call a number and enter the duration of the call on the seocnd line (in seconds)");
            phoneOne.AddCall(new Calls(Console.ReadLine(),int.Parse(Console.ReadLine())));
            Console.WriteLine("Call a number");
            phoneOne.AddCall(new Calls(Console.ReadLine(),int.Parse(Console.ReadLine())));
            Console.WriteLine("Call a number");
            phoneOne.AddCall(new Calls(Console.ReadLine(),int.Parse(Console.ReadLine())));
            Console.WriteLine("Call a number");
            phoneOne.AddCall(new Calls(Console.ReadLine(),int.Parse(Console.ReadLine())));
            Console.WriteLine("Call a number");
            phoneOne.AddCall(new Calls(Console.ReadLine(),int.Parse(Console.ReadLine())));

            // Display the information about the calls.
            foreach (var call in phoneOne.CallHistory)
            {

                Console.WriteLine($"Date and time of call {call.Date.ToShortDateString()} at {string.Format("{0}:{1}:{2}", call.Time.Hours, call.Time.Minutes, call.Time.Minutes)}. Called number: {call.DailedNum}. Call duration {call.Duration/60d:F3} min.");
            }

            double pricePerMin = 0.37;

            Console.WriteLine("The price of total calls is {0} BGN", phoneOne.CallsTotalPrice(pricePerMin));

            phoneOne.RemoveLongestCall();

            Console.WriteLine("The price of total calls is {0} BGN", phoneOne.CallsTotalPrice(pricePerMin));

            //Finally clear the call history and print it.
            phoneOne.DeleteCallHistory();
        }
        public static void Test()
        {
            //Create an instance of the GSM class
            GSM gsm = new GSM("Iphone 5S", "Apple");

            //Add few calls
            gsm.AddCall(new Call(new DateTime(2014, 1, 2, 12, 24, 0), "0889333333", 78));
            gsm.AddCall(new Call(new DateTime(2014, 2, 2, 18, 35, 0), "0888230531", 740));
            gsm.AddCall(new Call(new DateTime(2014, 3, 2, 18, 01, 0), "112", 1600));

            //Display the information about the calls
            Console.WriteLine(gsm.GetCallHistory());

            //Print the total price of the calls in the history
            Console.WriteLine("Total price: {0:F2}", gsm.CalculatePrice(PricePerMinute));
            Console.WriteLine();

            //Remove the longest call from the history
            gsm.CallHistory.RemoveAll(x => x.Duration == gsm.CallHistory.Max(y => y.Duration));

            //Calculate the total price again
            Console.WriteLine("Total price: {0:F2}", gsm.CalculatePrice(PricePerMinute));

            //Clear the call history and print it
            gsm.ClearCallHistory();
            Console.WriteLine();
            Console.WriteLine(gsm.GetCallHistory());
        }
Exemple #3
0
        static void Main()
        {
            GSMBattery nokiaBattery = new GSMBattery("BL-5BT",6);

            //nokiaBattery.BatteryModel = "BL-5BT";
            //nokiaBattery.HoursTalk = 6;
            //nokiaBattery.HoursIdle = 24;

            Display display = new Display();

            display.Size = 3;
            display.Colors = 4096;

            GSM nokia = new GSM("3310", "Nokia", 350);

            nokia.Battery = nokiaBattery;
            nokia.Display = display;

            //nokia.Owner = "Ivo";

            //nokia.Price = 350;
            //Console.WriteLine(nokia.Battery.Type);

            nokia.GSMInfo(nokia);
            //Console.WriteLine("Manifacturer: {0}", nokia.Manufacturer);
            //Console.WriteLine("Model: {0}",nokia.Model);
            //Console.WriteLine("Price: {0}lv",nokia.Price);
            //Console.WriteLine("Owner: {0}",nokia.Owner);
            //Console.WriteLine("Battery Characteristics:\n"+"Model: "+nokia.Battery.BatteryModel+"\n"+
            //    "Hours Talk: "+nokia.Battery.HoursTalk + "\n" +"Hours Idle: "+nokia.Battery.HoursIdle);
            //Console.WriteLine("Display Characteristics:\n"+ "Size: " + nokia.Display.Size +"\n"+
            //    "Colors: "+nokia.Display.Colors);
        }
 public static void Main()
 {
     GSM someGSM = new GSM("Xperia M4 Aqua Dual", "Sony", 520.87m, "Sony owner", new Battery("Xperia Aqua Battery", 488, 13.5f, Battery.BatteryType.LiIon), new Display(5f, 16777216));
     someGSM.AddCall(new Call(new DateTime(2015, 03, 15, 9, 16, 53), "+359874433434", 67));
     someGSM.AddCall(new Call(new DateTime(2015, 02, 16, 18, 3, 7), "+359882223344", 124));
     someGSM.AddCall(new Call(new DateTime(2015, 01, 12, 19, 3, 12), "+359898887766", 23));
     someGSM.AddCall(new Call(new DateTime(2015, 03, 16, 12, 37, 15), "+359884455566", 85));
     someGSM.AddCall(new Call(new DateTime(2015, 03, 17, 16, 43, 0), "+359879933222", 283));
     someGSM.AddCall(new Call(new DateTime(2015, 03, 12, 20, 55, 19), "+359897774433", 149));
     someGSM.AddCall(new Call(new DateTime(2015, 01, 28, 17, 55, 4), "+359884562233", 508));
     Console.WriteLine("Current Calls History:");
     foreach (Call item in someGSM.CallsList)
     {
         Console.WriteLine("Call time: {0}, Number: {1}, Duration: {2} sec.", item.CallDateTime, item.CallNumber, item.CallDuration);
     }
     Console.WriteLine("\nThe total price for the calls is {0}", someGSM.GetCallsPrice(0.37m));
     int longestCall = someGSM.CallsList[0].CallDuration;
     int longestCallIndex = 0;
     for (int i = 0; i < someGSM.CallsList.Count; i++)
     {
         if (someGSM.CallsList[i].CallDuration > longestCall)
         {
             longestCall = someGSM.CallsList[i].CallDuration;
             longestCallIndex = i;
         }
     }
     someGSM.DeleteCall(longestCallIndex);
     Console.WriteLine("\nThe total price for the calls without the longest call is {0}", someGSM.GetCallsPrice(0.37m));
     someGSM.ClearCalls();
     Console.WriteLine("\nCleared Calls History:");
     foreach (Call item in someGSM.CallsList)
     {
         Console.WriteLine("Call time: {0}, Number: {1}, Duration: {2} sec.", item.CallDateTime, item.CallNumber, item.CallDuration);
     }
 }
        public static void Test()
        {
            //Create an array of few instances of the GSM class
            GSM[] gsms = new GSM[3];

            string[]  models       = { "NokiaN95", "HTCDesire", "Iphone5S" };
            string[]  manufacturer = { "Nokia", "HTC", "Apple" };
            double?[] price        = { 400, 300, 1500 };
            string[]  owner        = { "Pesho", "Gosho", "Tosho" };

            Battery nokia95Battery   = new Battery("BL-5F", 220, 6.5, BatteryType.LiIon);
            Battery htcDesireBattery = new Battery("E205823", 340, 6.4, BatteryType.LiIon);
            Battery iPhone5SBattery  = new Battery("616-0613", 250, 10, BatteryType.LiIon);

            Battery[] batteries = { nokia95Battery, htcDesireBattery, iPhone5SBattery };

            Display nokia95Display   = new Display(2.6, 16000000);
            Display htcDesireDisplay = new Display(3.7, 16000000);
            Display iPhone5SDisplay  = new Display(4, 16000000);

            Display[] displays = { nokia95Display, htcDesireDisplay, iPhone5SDisplay };

            //Display the information about the GSMs in the array
            for (int i = 0; i < gsms.Length; i++)
            {
                gsms[i] = new GSM(models[i], manufacturer[i], price[i], owner[i], batteries[i], displays[i]);
                Console.WriteLine(gsms[i].ToString());
                Console.WriteLine();
            }

            //Display the information about the static property IPhone4S
            Console.WriteLine(GSM.IPhone4S);
        }
Exemple #6
0
        static void Main()
        {
            GSM firstPhone  = new GSM("HTC 10", "HTC Corporation");
            GSM secondPhone = new GSM("Y6", "Huawei", "Pesho");
            GSM thirdPhone  = new GSM("Nexus 5X", "LG", 1050.99, "Ivan", new Battery("abc", 24, 35), new Display(4, 255));

            //Create an array of few instances of the GSM class.
            GSM[] gsmCollection = { firstPhone, secondPhone, thirdPhone };

            //Display the information about the GSMs in the array.
            foreach (var phone in gsmCollection)
            {
                Console.WriteLine(phone);
                Console.WriteLine();
            }

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

            //Create an instance of the GSM class.
            GSM phoneOne = new GSM("Galaxy S4", "Samsung", 450.99, "M", new Battery("LiIon", 100), new Display(5.0, 16));

            //Add few calls.

            Console.WriteLine("Call a number and enter the duration of the call on the seocnd line (in seconds)");
            phoneOne.AddCall(new Calls(Console.ReadLine(), int.Parse(Console.ReadLine())));
            Console.WriteLine("Call a number");
            phoneOne.AddCall(new Calls(Console.ReadLine(), int.Parse(Console.ReadLine())));
            Console.WriteLine("Call a number");
            phoneOne.AddCall(new Calls(Console.ReadLine(), int.Parse(Console.ReadLine())));
            Console.WriteLine("Call a number");
            phoneOne.AddCall(new Calls(Console.ReadLine(), int.Parse(Console.ReadLine())));
            Console.WriteLine("Call a number");
            phoneOne.AddCall(new Calls(Console.ReadLine(), int.Parse(Console.ReadLine())));

            // Display the information about the calls.
            foreach (var call in phoneOne.CallHistory)
            {
                Console.WriteLine($"Date and time of call {call.Date.ToShortDateString()} at {string.Format("{0}:{1}:{2}", call.Time.Hours, call.Time.Minutes, call.Time.Minutes)}. Called number: {call.DailedNum}. Call duration {call.Duration/60d:F3} min.");
            }

            double pricePerMin = 0.37;

            Console.WriteLine("The price of total calls is {0} BGN", phoneOne.CallsTotalPrice(pricePerMin));

            phoneOne.RemoveLongestCall();

            Console.WriteLine("The price of total calls is {0} BGN", phoneOne.CallsTotalPrice(pricePerMin));

            //Finally clear the call history and print it.
            phoneOne.DeleteCallHistory();
        }
Exemple #7
0
        static void Main()
        {
            GSM gsm = new GSM("3212", "Nokia");

            gsm.Call = new Call("0889675432");

            Thread.Sleep(200);

            gsm.Call = new Call("0898765412");

            Thread.Sleep(20);

            gsm.Call = new Call("0889562134");

            Console.WriteLine("Call history:");

            foreach (var call in Call.CallHystory)
            {
                Console.WriteLine(call);
            }

            Console.WriteLine();

            Console.WriteLine("The price for the calls is: " + gsm.CallPrice(0.37M) + "lv");

            Console.WriteLine();

            gsm.CallHistory.Remove(gsm.Call.LongestCall());

            Console.WriteLine("Call history after removing the longest call:");

            foreach (var call in Call.CallHystory)
            {
                Console.WriteLine(call);
            }

            Console.WriteLine();

            Console.WriteLine("The price for the calls is: " + gsm.CallPrice(0.37M) + "lv");

            Console.WriteLine();

            gsm.ClearCallHistory();

            Console.WriteLine("Call history after clearing: ");

            foreach (var call in Call.CallHystory)
            {
                Console.WriteLine(call);
            }
        }
 static void Main()
 {
     GSM[] GSMArray = new GSM[4];
     GSMArray[0] = new GSM("Galaxy E7", "Samsung", 648, "Samsung owner", new Battery("E7 Battery", 800, 18, Battery.BatteryType.LiIon), new Display(5.5f, 16777216));
     GSMArray[1] = new GSM("Lumia 640 XL LTE", "Microsoft", 394.24m, "MS owner", new Battery("Lumia 640 Battery", 888, 24, Battery.BatteryType.LiIon), new Display(5.7f, 16777216));
     GSMArray[2] = new GSM("Xperia M4 Aqua Dual", "Sony", 520.87m, "Sony owner", new Battery("Xperia Aqua Battery", 488, 13.5f, Battery.BatteryType.LiIon), new Display(5f, 16777216));
     GSMArray[3] = new GSM("G3 Screen", "LG", 899, "LG owner", new Battery("LG G3 Battery", 640, 13f, Battery.BatteryType.LiIon), new Display(5.9f, 16777216));
     for (int i = 0; i < GSMArray.Length; i++)
     {
         Console.WriteLine(GSMArray[i].ToString());
         Console.WriteLine(new String('=', 30));
     }
     Console.WriteLine(GSM.Iphone4S);
 }
 static void Main()
 {
     GSM[] GSMArray = new GSM[4];
     GSMArray[0] = new GSM("Galaxy E7", "Samsung", 648, "Samsung owner", new Battery("E7 Battery", 800, 18, Battery.BatteryType.LiIon), new Display(5.5f, 16777216));
     GSMArray[1] = new GSM("Lumia 640 XL LTE", "Microsoft", 394.24m, "MS owner", new Battery("Lumia 640 Battery", 888, 24, Battery.BatteryType.LiIon), new Display(5.7f, 16777216));
     GSMArray[2] = new GSM("Xperia M4 Aqua Dual", "Sony", 520.87m, "Sony owner", new Battery("Xperia Aqua Battery", 488, 13.5f, Battery.BatteryType.LiIon), new Display(5f, 16777216));
     GSMArray[3] = new GSM("G3 Screen", "LG", 899, "LG owner", new Battery("LG G3 Battery", 640, 13f, Battery.BatteryType.LiIon), new Display(5.9f, 16777216));
     for (int i = 0; i < GSMArray.Length; i++)
     {
         Console.WriteLine(GSMArray[i].ToString());
         Console.WriteLine(new String('=', 30));
     }
     Console.WriteLine(GSM.Iphone4S);
 }
Exemple #10
0
        public static void Main()
        {
            GSM someGSM = new GSM("Xperia M4 Aqua Dual", "Sony", 520.87m, "Sony owner", new Battery("Xperia Aqua Battery", 488, 13.5f, Battery.BatteryType.LiIon), new Display(5f, 16777216));

            someGSM.AddCall(new Call(new DateTime(2015, 03, 15, 9, 16, 53), "+359874433434", 67));
            someGSM.AddCall(new Call(new DateTime(2015, 02, 16, 18, 3, 7), "+359882223344", 124));
            someGSM.AddCall(new Call(new DateTime(2015, 01, 12, 19, 3, 12), "+359898887766", 23));
            someGSM.AddCall(new Call(new DateTime(2015, 03, 16, 12, 37, 15), "+359884455566", 85));
            someGSM.AddCall(new Call(new DateTime(2015, 03, 17, 16, 43, 0), "+359879933222", 283));
            someGSM.AddCall(new Call(new DateTime(2015, 03, 12, 20, 55, 19), "+359897774433", 149));
            someGSM.AddCall(new Call(new DateTime(2015, 01, 28, 17, 55, 4), "+359884562233", 508));
            Console.WriteLine("Current Calls History:");
            foreach (Call item in someGSM.CallsList)
            {
                Console.WriteLine("Call time: {0}, Number: {1}, Duration: {2} sec.", item.CallDateTime, item.CallNumber, item.CallDuration);
            }
            Console.WriteLine("\nThe total price for the calls is {0}", someGSM.GetCallsPrice(0.37m));
            int longestCall      = someGSM.CallsList[0].CallDuration;
            int longestCallIndex = 0;

            for (int i = 0; i < someGSM.CallsList.Count; i++)
            {
                if (someGSM.CallsList[i].CallDuration > longestCall)
                {
                    longestCall      = someGSM.CallsList[i].CallDuration;
                    longestCallIndex = i;
                }
            }
            someGSM.DeleteCall(longestCallIndex);
            Console.WriteLine("\nThe total price for the calls without the longest call is {0}", someGSM.GetCallsPrice(0.37m));
            someGSM.ClearCalls();
            Console.WriteLine("\nCleared Calls History:");
            foreach (Call item in someGSM.CallsList)
            {
                Console.WriteLine("Call time: {0}, Number: {1}, Duration: {2} sec.", item.CallDateTime, item.CallNumber, item.CallDuration);
            }
        }
Exemple #11
0
 //Static constructor for iPhone
 static GSM()
 {
     iPhone4S = new GSM("iPhone4S", "Apple", 999.99, "Gosho", new Battery("Li-Po", 200, 14), new Display(3.5, 16));
 }
Exemple #12
0
 //Static constructor for iPhone
 static GSM()
 {
     iPhone4S = new GSM("iPhone4S", "Apple", 999.99, "Gosho", new Battery("Li-Po", 200, 14), new Display(3.5, 16));
 }
Exemple #13
0
 public void Info(GSM gsm)
 {
     Console.WriteLine(gsm.ToString());
 }