Exemple #1
0
Fichier : GSM.cs Projet : HD-LB/OOP
 //Constructors ctor + Tab Tab
 #region Constructors
 static GSM()
 {
     iPhone4S = new GSM("iPhone 4S", "Apple", 1000.0m, "Person", new Battery(), new Display()
     {
         Size = 4, NumberOfColors = "16M"
     });
 }
Exemple #2
0
        static void Main()
        {
            var gsm = new GSM("Nokia 3310", "Nokia", 234.5m, "Ivan");

            Console.WriteLine(gsm);

            for (int i = 0; i < 10; i++)
            {
                gsm.AddCall(new Call()
                {
                    DailedPhoneNumber = "0001" + 1,
                    Duration          = (uint)((i + 1) * 10)
                }
                            );
            }
            Console.WriteLine(gsm.CalculateTotalCost(0.12m));

            Console.WriteLine();
            Console.WriteLine();

            var maxCall = new Call();

            foreach (Call call in gsm.CallHistory)
            {
                Console.WriteLine(call);
                if (maxCall.Duration < call.Duration)
                {
                    maxCall = call;
                }
            }

            gsm.DeleteCall(maxCall);
            Console.WriteLine(gsm.CalculateTotalCost(0.12m));
        }
        static void Main()
        {
            GSM mobilePhone = new GSM();

            mobilePhone.Manufacturer = "Nokia";
            Console.WriteLine("Manufacturer: {0}", mobilePhone.Manufacturer);

            mobilePhone.Model = "Lumia 925";
            Console.WriteLine("Model: {0}", mobilePhone.Model);

            mobilePhone.Price = 540.56M;
            Console.WriteLine("Price: {0}", mobilePhone.Price);

            mobilePhone.Owner = "Mitko";
            Console.WriteLine("Owner: {0}", mobilePhone.Owner);

            mobilePhone.Battery.BatteryModel = "Nokia Batery";
            Console.WriteLine("Battery Model: {0}", mobilePhone.Battery.BatteryModel);

            mobilePhone.Battery.HoursIdle = 10;
            Console.WriteLine("Hours idle: {0}", mobilePhone.Battery.HoursIdle);

            mobilePhone.Battery.HoursTalk = 5;
            Console.WriteLine("Hours talk: {0}", mobilePhone.Battery.HoursTalk);

            mobilePhone.Display.Size = 5.2;
            Console.WriteLine("Display size: {0}", mobilePhone.Display.Size);

            mobilePhone.Display.NumberOfColors = 256000000;
            Console.WriteLine("Number of colors: {0}", mobilePhone.Display.NumberOfColors);
            Console.WriteLine();
        }
        static void Main()
        {
            GSM mobilePhone = new GSM();
            mobilePhone.Manufacturer = "Nokia";
            Console.WriteLine("Manufacturer: {0}", mobilePhone.Manufacturer);

            mobilePhone.Model = "Lumia 925";
            Console.WriteLine("Model: {0}", mobilePhone.Model);

            mobilePhone.Price = 540.56M;
            Console.WriteLine("Price: {0}", mobilePhone.Price);

            mobilePhone.Owner = "Mitko";
            Console.WriteLine("Owner: {0}", mobilePhone.Owner);

            mobilePhone.Battery.BatteryModel = "Nokia Batery";
            Console.WriteLine("Battery Model: {0}", mobilePhone.Battery.BatteryModel);

            mobilePhone.Battery.HoursIdle = 10;
            Console.WriteLine("Hours idle: {0}", mobilePhone.Battery.HoursIdle);

            mobilePhone.Battery.HoursTalk = 5;
            Console.WriteLine("Hours talk: {0}", mobilePhone.Battery.HoursTalk);

            mobilePhone.Display.Size = 5.2;
            Console.WriteLine("Display size: {0}", mobilePhone.Display.Size);

            mobilePhone.Display.NumberOfColors = 256000000;
            Console.WriteLine("Number of colors: {0}", mobilePhone.Display.NumberOfColors);
            Console.WriteLine();
        }
 public static void PrintGSMGenerator(GSM[] mobiles)
 {
     foreach (var gsm in mobiles)
     {
         Console.WriteLine(gsm.ToString());
     }
 }
        public static GSM[] GeneratorGSM(int numberGSMs)
        {
            GSM[] gsms = new GSM[numberGSMs];

            for (int i = 0; i < numberGSMs; i++)
            {
                int manufacturerIndex = gsmRandom.Next(0, 9);

                gsms[i] = new GSM(models[gsmRandom.Next(models.GetLength(0)), manufacturerIndex],
                                  (Manufacturer)manufacturerIndex, gsmRandom.Next(6, 2100),
                                  owners[gsmRandom.Next(0, owners.Length)],
                                  displays[gsmRandom.Next(0, displays.Length)],
                                  batteries[gsmRandom.Next(0, batteries.Length)]);
            }
            return(gsms);
        }
        public static GSM[] GeneratorGSM(int numberGSMs)
        {
            GSM[] gsms = new GSM[numberGSMs];
           
            for (int i = 0; i < numberGSMs; i++)
            {
                int manufacturerIndex = gsmRandom.Next(0, 9);

                gsms[i] = new GSM(models[gsmRandom.Next(models.GetLength(0)),manufacturerIndex],
                                 (Manufacturer)manufacturerIndex, gsmRandom.Next(6,2100),
                                 owners[gsmRandom.Next(0,owners.Length)],
                                 displays[gsmRandom.Next(0,displays.Length)],
                                 batteries[gsmRandom.Next(0,batteries.Length)]);                                  
            }
            return gsms;       
        } 
        static void Main()
        {
            //Print the Iphone4S Static
            GSMTest.PrintIphone4S();

            GSM my = new GSM("Model", Manufacturer.APPLE, 1000.00);

            Console.WriteLine(my.ToString());

            // Test the mobile phones specifics, you can change the number of GSM-s from the number in method GeneratorGSM()
            GSMTest.PrintGSMGenerator(GSMTest.GeneratorGSM(6));


            //Problem 12 Solved

            GSMCallHistoryTest.AddTestCallsInHistory();        // Add definited calls from array into the List<Calls>
            GSMCallHistoryTest.DisplayCalltestHistory();       // Print the call history for the moment
            Console.WriteLine(Environment.NewLine);

            GSMCallHistoryTest.CalculateAndPrintTestcallsPrice();  // Calculate and print the price of all calls in the List<Calls) with fixed price 0.37
            Console.WriteLine(Environment.NewLine);

            Console.WriteLine("The longest call is removing...");
            GSMCallHistoryTest.RemoveLongestCall();                     // Remove the longest call from the List<Calls>
            Console.WriteLine(Environment.NewLine);


            Console.WriteLine("After the longest call was removed:");
            Console.WriteLine(Environment.NewLine);

            GSMCallHistoryTest.CalculateAndPrintTestcallsPrice();  // Calculate and print the price of all calls in the List<Calls) with fixed price 0.37
            Console.WriteLine(Environment.NewLine);                // after the removing longest call


            GSMCallHistoryTest.DisplayCalltestHistory();    // Print call history
            Console.WriteLine(Environment.NewLine);

            Console.WriteLine("Now the phone calls are clearing from the history...");
            GSMCallHistoryTest.testGSM.ClearCallHistory();      // Clear data history
            Console.WriteLine(Environment.NewLine);

            GSMCallHistoryTest.DisplayCalltestHistory();      // Print empty history
            Console.WriteLine("WELL DONE\n");
        }
Exemple #9
0
        static void Main()
        {
            DateTime date1 = new DateTime(1994, 12, 25, 18, 36, 45);
            DateTime date2 = new DateTime(2005, 11, 12, 21, 30, 40);
            DateTime date3 = new DateTime(2012, 10, 9, 20, 30, 38);
            DateTime date4 = new DateTime(2015, 1, 9, 21, 38, 31);

            GSM newGSM = new GSM("Galaxy Dous", "Samsung", "Ivan", 450, 5, 16000, BatteryTypes.LiIon, 2000, 150);

            newGSM.AddCall(GSM.callHistory, new Calls(date1, "0888999987", 123));
            newGSM.AddCall(GSM.callHistory, new Calls(date2, "0888999988", 143));
            newGSM.AddCall(GSM.callHistory, new Calls(date1, "0888988987", 153));
            newGSM.AddCall(GSM.callHistory, new Calls(date1, "0888987988", 163));
            for (int i = 0; i < newGSM.CallHistory.Count; i++)
            {
                Console.WriteLine(newGSM.CallHistory[i].ToString());
            }
            Console.WriteLine();
            Console.WriteLine("The price is {0:F2} leva. ", newGSM.CallPrice(newGSM.CallHistory, 0.37));
            int   tmpSeconds = int.MinValue;
            Calls tmpCall    = new Calls();

            foreach (Calls Call in newGSM.CallHistory)
            {
                if (Call.Duration > tmpSeconds)
                {
                    tmpCall = Call;
                }
            }
            newGSM.DeleteCall(GSM.callHistory, tmpCall);
            Console.WriteLine();
            Console.WriteLine("The new price is {0:F2} leva. ", newGSM.CallPrice(newGSM.CallHistory, 0.37));
            newGSM.ClearHistory(GSM.callHistory);
            Console.WriteLine();
            for (int i = 0; i < newGSM.CallHistory.Count; i++)
            {
                Console.WriteLine(newGSM.CallHistory[i].ToString());
            }
            Console.WriteLine("The list is empty so nothing is going to show. ");
        }
Exemple #10
0
 static void Main()
 {
     GSM phone = new GSM("Nokia 3310", "Nokia", 999.01m, "PacoGaroPenio");
     phone.AddCall(new Call(11));
     phone.AddCall(new Call(1511));
     phone.AddCall(new Call(123));
     Console.WriteLine(phone.CalculateTotalPrice(0.37m));
     phone.RemoveCall(new Call(1511));
     Console.WriteLine("Total Price after removing: {0}", phone.CalculateTotalPrice(0.37m));
     phone.ClearCalls();
     Console.WriteLine("Total Price after clearing: {0}", phone.CalculateTotalPrice(0.37m));
 }