Ejemplo n.º 1
0
        static void Main()
        {
            //the data is fake
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
            GSM[] gsms = new GSM[3];

            Display display1 = new Display(4F, "16M");
            Battery battery1 = new Battery(450, 30, BatteryType.NiCd);
            gsms[0] = new GSM("Nokia 808", "Nokia Corporation", 345.00M, "Petar Petrov", battery1, display1);

            Display display2 = new Display(2.5F, "256K");
            Battery battery2 = new Battery(950, 35, BatteryType.LiIon);
            gsms[1] = new GSM("Samsung Ace", "Samsung Group", 545.00M, "Ivan Ivanov", battery2, display2);

            Display display3 = new Display(5.1F, "16M");
            Battery battery3 = new Battery(700, 25, BatteryType.NiMH);
            gsms[2] = new GSM("Motorola", "Motorola Solutions, Inc.", 45.00M, "Vasil Vasilev", battery3, display3);

            foreach (var gsm in gsms)
            {
                Console.WriteLine(gsm.ToString());
                Console.WriteLine();
            }

            //Display the information about the static property IPhone4S.
            GSM.IPhone4S.Owner = "Alis";
            Console.WriteLine(GSM.IPhone4S.ToString());
        }
        // The following method is executed in the Main() method which is located in the TestExecution class
        public static void CallHistoryTest()
        {
            GSM myGSM = new GSM("Galaxy Note III", "Samsung");  // Initialize a new phone

            myGSM.AddCall(DateTime.Now.AddSeconds(8432), "0888123456", 36);         // Stuff it's call history with entries
            myGSM.AddCall(DateTime.Now.AddSeconds(12415), "+359888123456", 511);
            myGSM.AddCall(DateTime.Now.AddSeconds(22425), "0877123456", 14);
            myGSM.AddCall(DateTime.Now.AddSeconds(29434), "+359888123456", 643);
            myGSM.AddCall(DateTime.Now.AddSeconds(42213), "0899123456", 186);
            myGSM.AddCall(DateTime.Now.AddSeconds(52411), "+359888123456", 152);

            myGSM.DisplayCallHistory(); // Display the call history
            Console.WriteLine();
            Console.WriteLine("Price: {0:f2}", myGSM.TotalPrice(.37));  // Display the price for all the entries
            Console.WriteLine();

            myGSM.DeleteCall(FindIndexOfLongestCall(myGSM));    // Remove the entry at the index where the longest call is kept

            myGSM.DisplayCallHistory();
            Console.WriteLine();
            Console.WriteLine("Price: {0:f2}", myGSM.TotalPrice(.37));  // Display the price for the entries that remain
            Console.WriteLine();

            myGSM.ClearHistory();       // Clear the history

            myGSM.DisplayCallHistory();
            Console.WriteLine();
            Console.WriteLine("Price: {0:f2}", myGSM.TotalPrice(.37));
            Console.WriteLine();
        }
        public void GSMCallHistoryTesting()
        {
            // Create an instance of the GSM class.
            GSM testGsm = new GSM("Nokia", "TelerikCorp");

            // Add few calls.
            testGsm.AddCall("9873432142", 53);
            testGsm.AddCall("9811433144", 123);
            testGsm.AddCall("9872411149", 41);

            // Display the information about the calls.
            testGsm.ShowCallHistory();

            // Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            Console.WriteLine("Total call price: " + testGsm.TotalCallPrice());

            //  Remove the longest call from the history and calculate the total price again.
            testGsm.DeleteCall(2);
            Console.WriteLine("Removed Longest call!");
            Console.WriteLine("Total call price: " + testGsm.TotalCallPrice());

            //// Clear the call history and print it.
            //testGsm.ClearCallHistory();
            //Console.WriteLine("Cleared call history!");
            //testGsm.ShowCallHistory();
        }
Ejemplo n.º 4
0
        public static void GTest()
        {
            GSM one = new GSM("titans2", "DooGee", 1200.99m, "the owner",
                              new Battery("batModel", "batManufacturer", BatteryTypes.NiMH),
                              new Display("displModel", "displManufacturer"));
            Display ds = new Display("ds", "ds", 0.5m);
            Battery b  = new Battery("s", "m", BatteryTypes.LiIon);
            //Battery ba = new Battery()

            // one.Model = "";
            // one.Manufacturer = "";
            // one.Price = -25;
            // one.Owner = "";

            // one.Battery.Manufacturer = "";
            // one.Battery.Model = "";

            // one.Display.Manufacturer = "";
            // one.Display.Model = "";

            // Console.WriteLine(one.ToString());

            GSM ip = GSM.iphone4s;

            GSM[] phones = { one, ip };

            foreach (var phone in phones)
            {
                Console.WriteLine(new string('x', 45));
                Console.WriteLine(phone.ToString());
            }
        }
 //add few calls in the phone
 public GSMCallHistoryTest()
 {
     phone = new GSM("Diamond", "HTC", "Pesho", 700.0, battery1, display1);
     phone.AddCall("0888123456", 133, DateTime.Parse("22.02.2013"),TimeSpan.Parse("15:16"));
     phone.AddCall("0888000001", 15, DateTime.Parse("20.02.2013"), TimeSpan.Parse("10:20"));
     phone.AddCall("0888000002", 62, DateTime.Parse("19.02.2013"), TimeSpan.Parse("22:30"));
 }
Ejemplo n.º 6
0
        static void Main()
        {
            Display someDisplay = new Display("4.5inch", "165Million");
            Battery someBattery = new Battery("Varta", 10.00, 10.00);

            GSM myPhone = new GSM("G3", "JIAYU", "Pencho", 390.00m, someBattery, someDisplay);

            myPhone.AddCallToHist(DateTime.Now, "088617555", 180);
            myPhone.AddCallToHist(DateTime.Now, "099953312", 2000);
            myPhone.AddCallToHist(DateTime.Now, "125989364", 369);
            myPhone.AddCallToHist(DateTime.Now, "058933153", 600);

            myPhone.DisplayCallHistory();
            Console.WriteLine("Price for all calls");
            //calculating totalPrice for all calls
            decimal pricePerMinute = 0.37m;
            decimal totalPrice = 0m;
            totalPrice=myPhone.TotalPriceCall(pricePerMinute);
            Console.WriteLine(totalPrice);

            //Remove LongestCall and calculating price again
            myPhone.RemoveLongestCall();
            Console.WriteLine("Price for all calls after removing the longest call");
            totalPrice = myPhone.TotalPriceCall(pricePerMinute);
            Console.WriteLine(totalPrice);
            myPhone.DisplayCallHistory();
            myPhone.ClearCallHistory();
            Console.WriteLine("This is cleared call history:");
            myPhone.DisplayCallHistory();
        }
Ejemplo n.º 7
0
        public static void CallHistoryTest()
        {
            GSM testGSM = GSM.IPhone4s;

            testGSM.AddCall("0999-999-999", 2.3);
            testGSM.AddCall("0888-999-999", 12.4);
            testGSM.AddCall("0777-999-999", 4.34);
            testGSM.AddCall("0666-999-999", 8.2);
            testGSM.AddCall("0555-999-999", 11.2);
            Console.WriteLine("-------Showing added calls--------");
            testGSM.ShowCallHistory();

            Console.WriteLine("------Calculating total price for calls------");
            double totalCallPrice = testGSM.CalculateCallsTotalPrice();

            Console.WriteLine("{0:C}", totalCallPrice);

            Console.WriteLine("----Removing longest call and recalculating-----");
            testGSM.RemoveLongestCallEntry();
            testGSM.ShowCallHistory();
            totalCallPrice = testGSM.CalculateCallsTotalPrice();
            Console.WriteLine("{0:C}", totalCallPrice);

            Console.WriteLine("----Clearing call history-----");
            testGSM.ClearCallHistory();
            testGSM.ShowCallHistory();
        }
Ejemplo n.º 8
0
        public static void Start()
        {
            //Create an instance of the GSM class.
            var myPhone = new GSM("GalaxyS6", "Samsung");

            //Add few calls.
            myPhone.AddCall(new Call(new DateTime(2015, 3, 5, 9, 30, 10), "0883448036", 140));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 4, 10, 12, 53), "0883428135", 230));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 12, 19, 3, 32), "0883451438", 423));

            //Print call information
            myPhone.PrintCallHistory();
            Console.WriteLine();

            //Print the total price of the calls in the history for 0.37 per minute
            Console.WriteLine("Total calls price: ${0:0.##}", myPhone.GetCallsTotalPrise(0.37M));

            //Remove the longest call from the history and calculate the total price again
            var longestCall = myPhone.CallHistory.OrderByDescending(x => x.Duration).First();
            myPhone.DeleteCall(longestCall);
            Console.WriteLine("Longest call removed!");
            Console.WriteLine("Total calls price: ${0:0.##}", myPhone.GetCallsTotalPrise(0.37M));
            Console.WriteLine();
            myPhone.PrintCallHistory();

            //Finally clear the call history and print it.
            myPhone.ClearHistory();
            Console.WriteLine("History cleared!");
            myPhone.PrintCallHistory();
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            var device = new GSM("Touch Pro 2", "HTC", "Vlado");

            Call firstCall = new Call(180);
            device.AddCall(firstCall);

            Console.WriteLine(device.CallHystoryPrice());
        }
Ejemplo n.º 10
0
 //Static constructor
 static GSM()
 {
     galaxyS6 = new GSM("GalaxyS6", "Samsung")
     {
         Price = 1140.30m,
         Owner = "Jake Miller",
         battery = new Battery("Alk")
         {
             HoursIdle = 200,
             HoursTalk = 40,
             Type = BatteryType.LiIon
         },
         Display = new Display(5.1, 16M)
     };
 }
Ejemplo n.º 11
0
 static GSM()
 {
     iphone4S = new GSM(
         "iPhone 4S",
         "Apple", 1000.0m,
         "Stamat",
         new Battery()
     {
         Model = "Iphone Battery Yo!", HoursIdle = 76, HoursTalk = 15
     },
         new Display()
     {
         Size = 4, NumberOfColors = 16000000
     },
         BatteryType.OEM);
 }
Ejemplo n.º 12
0
        public void GSMTesting()
        {
            GSM instance1 = new GSM("Nokia", "Connecting People", 140000, "HappyOwner",
                                    new Battery("BestBatteryEVER", 1000, 10000, Battery.BatType.AlienTech), new Display(1000, 1000, 16000000));

            GSM instance2 = new GSM("Kia", "Thailand");

            GSM instance3 = new GSM("Somebrand", "SomeManufacturer", 100, "Az", new Battery(), new Display());

            GSM[] testAll = new GSM[] { instance1, instance2, instance3 };

            Console.WriteLine(testAll[0].ToString());

            Console.WriteLine(GSM.IPhone4S);
            Console.ReadLine();
        }
        // Method used to find the index of the longest call in the call history
        static int FindIndexOfLongestCall(GSM myGSM)
        {
            uint maxDuration = 0;
            int indexOfLongestCall = 0;

            for (int i = 0; i < myGSM.CallHistory.Count; i++)
            {
                if (myGSM.CallHistory[i].CallDuration > maxDuration)
                {
                    maxDuration = myGSM.CallHistory[i].CallDuration;
                    indexOfLongestCall = i;
                }
            }

            return indexOfLongestCall;
        }
Ejemplo n.º 14
0
        // The following method is executed in the Main() method which is located in the TestExecution class
        public static void Test()
        {
            GSM[] GSMArray = new GSM[6];    // Each of the elements is initialized by using all the different constructors

            GSMArray[0] = new GSM("One", "HTC");
            GSMArray[1] = new GSM("Lumia 1020", "Nokia", 1299.00);
            GSMArray[2] = new GSM("Galaxy S4", "Samsung", 899.00, "Pesho Peshov");
            GSMArray[3] = new GSM("ATIV S", "Samsung", 599.00, new Battery("I8750", 168, 8, BatteryType.LiIon));
            GSMArray[4] = new GSM("Windows Phone 8X", "HTC", 699.00, new Display(4.3, 16000000));
            GSMArray[5] = GSM.IPhone4S;

            for (int i = 0; i < GSMArray.Length; i++)  // Use the overridden ToString method to display the phone info on the console
            {
                Console.WriteLine(GSMArray[i].ToString());
                Console.WriteLine();
            }
        }
Ejemplo n.º 15
0
        private static void GSMTest()
        {
            GSM test1 = new GSM("Nokia", "Connecting People", 140000
                                , "HappyOwner", new Battery("BestBatteryEVER", 1000, 10000, Battery.Type.AlienTech), new Display(1000, 1000, 16000000));

            GSM test2 = new GSM("Kia", "Thailand");

            GSM test3 = new GSM("Somebrand", "SomeManufacturer", 100, "Az", new Battery(), new Display());

            GSM[] testAll = new GSM[] { test1, test2, test3 };

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

            Console.WriteLine(GSM.IPhone4S);
        }
Ejemplo n.º 16
0
        static void Main()
        {
            var gsm = new GSM("Samsung", "S7 Edge+", 1200.0m, "Stamat", new Battery {
                Model = "G1567", HoursIdle = 78, HoursTalk = 20,
            }, new Display {
                Size = 5.4, NumberOfColors = 64000000
            }, BatteryType.NiCd);

            gsm.CallHistory.Add(new Call()
            {
                Duration = 1000, DialedPhone = "+359********9"
            });

            for (int i = 0; i < 10; i++)
            {
                gsm.AddCall(new Call()
                {
                    DialedPhone = "+359********" + i,
                    Duration    = (uint)(i + 1) * 120
                });
            }

            var maxCall = new Call();

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

            Console.WriteLine("Total calls: {0}", gsm.CalculateTotalCost(0.37m));
            gsm.DeleteCall(maxCall);
            Console.WriteLine("Total calls without Longest Call: {0}", gsm.CalculateTotalCost(0.37m));

            Console.WriteLine(gsm.ToString());

            Console.WriteLine(GSM.Iphone4S);
        }
Ejemplo n.º 17
0
        public static void Start()
        {
            //Array of GSM objects
            var gsmDevices = new GSM[]
            {
                new GSM("HTC One", "HTC"),
                new GSM("Lumia", "Nokia"),
                new GSM("iPhone 4S", "Apple"),
                new GSM("Galaxy S6 Edge", "Samsung"),

            };

            //Display info about each object
            foreach (var gsmDevice in gsmDevices)
            {
                Console.WriteLine(gsmDevice.ToString());
            }

            //Disaply GalaxyS6 info
            Console.WriteLine(GSM.GalaxyS6.ToString());
        }
Ejemplo n.º 18
0
        static void Main()
        {
            GSM[] gsmDevices = new GSM[5];

            gsmDevices[0] = new GSM("N95", "Nokia", 650.60m, "Kukata",
                                    new Display(15, 65000), new Battery("Takashi", Battery.BatteryType.NiMH, 0, 0));
            gsmDevices[1] = new GSM("Touch Pro 2", "HTC", "VGeorgiev");
            gsmDevices[2] = new GSM("Galaxy", "Samsung", "Penka");
            gsmDevices[3] = new GSM("Touch Diamond", "HTC", "Stoki");
            gsmDevices[4] = new GSM();

            for (int i = 0; i < gsmDevices.Length; i++)
            {
                Console.WriteLine("Manufacturer: {0} , Model: {1}",
                                  gsmDevices[i].Manufacturer, gsmDevices[i].Model);
            }

            Console.WriteLine();

            Console.WriteLine(GSM.IPhone4S.ToString());
        }
Ejemplo n.º 19
0
        static void Main(string[] args)
        {
            //Create an array of few instances of the GSM class.
            GSM[] gsmArray = new GSM[3];
            Display display = new Display(4.8, 16000000);
            Battery battery = new Battery("NiMH", 30.7, 6.7);
            battery.batteryType = BatteryType.NiMH;

            //initialize the phones
            gsmArray[0] = new GSM("Galaxy SIII", "Samsung", 870, "Samuel L. Jackson", battery, display);
            gsmArray[1] = new GSM("Milestone 2", "Motorola", 300, "Garry Barlow", battery, display);
            gsmArray[2] = new GSM("Sony", "Xperia 8", 220, "Zigs Gugenheim", battery, display);

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

            //Display the information about the static property IPhone4S
            Console.WriteLine(GSM.IPhone4S);
        }
Ejemplo n.º 20
0
        public static void HistoryTest()
        {
            GSM one = new GSM("mod", "manu");

            Console.WriteLine(one.CallHistory.Count);

            Call someCall = new Call("135", 100);
            Call two      = new Call("6541651", 102);

            one.AddCall(someCall);
            Console.WriteLine(one.CallHistory.Count);
            one.AddCall(two);
            Console.WriteLine(one.CallHistory.Count);

            Console.WriteLine(one.CalcPriceOfCalls());


            Console.WriteLine(one.ToString());

            one.RemoveLongestCall();

            Console.WriteLine(one.ToString());
        }
Ejemplo n.º 21
0
        static void Main()
        {
            //create array of gsm object and display info + info iphone4s
            GSM[] gsmArray = new GSM[3]
            {
                new GSM("Asha 1", "Nokia", owner: "Peter"),
                new GSM("One", "HTC", new Battery(Battery.BatteryType.LiPoly, "superBat"), new Display(6, 2640000), price: 999.90),
                new GSM("Xperia", "Sony")
            };

            foreach (var gsm in gsmArray)
            {
                Console.WriteLine(gsm);
                Console.WriteLine();
            }
            Console.WriteLine(GSM.IPhone4s);

            //test the call methods and history
            Console.BackgroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("---------STARTING CALL TEST-------");
            Console.ResetColor();
            GSMCallHistoryTest.CallHistoryTest();
        }
Ejemplo n.º 22
0
        private static void GSMCallHistoryTest()
        {
            GSM testGsm = new GSM("Nokia", "TelerikCorp");

            testGsm.AddCall("+359873432142", 53);
            testGsm.AddCall("+359811432142", 123);
            testGsm.AddCall("+359872412142", 41);
            testGsm.AddCall("+359833332142", 72);
            testGsm.AddCall("+359614432142", 231);

            testGsm.ShowCallHistory();

            Console.WriteLine("Total call price: " + testGsm.TotalCallPrice());

            testGsm.DeleteCall(5);
            Console.WriteLine("Removed Longest call!");

            Console.WriteLine("Total call price: " + testGsm.TotalCallPrice());

            testGsm.ClearCallHistory();
            Console.WriteLine("Cleared call history!");
            testGsm.ShowCallHistory();
        }
Ejemplo n.º 23
0
        static void Main()
        {
            GSM[] arrayOfPhones = new GSM[3];

            Battery nokiaBattery = new Battery("BL-5K", BatteryType.LiIon, 20, 5);
            Display nokiaDisplay = new Display("320x240", 4096);
            GSM     nokiaN86     = new GSM("N86 8MP", "NOKIA", 150.4m, "Lora", nokiaBattery, nokiaDisplay);

            Battery samsungBattery = new Battery("2100 mAh", BatteryType.LiIon, 25, 6);
            Display samsungDisplay = new Display("720 x 1280", 16000000);
            GSM     samsungS3      = new GSM("Galaxy S3", "Samsung", 900.45m, "Nora", samsungBattery, samsungDisplay);

            Battery lgBattery = new Battery("1500 mAh", BatteryType.LiIon, 3, 2);
            Display lgDisplay = new Display("480x800", 65535);
            GSM     LGOptimus = new GSM("Optimus 3D", "LG", 778.2m, "Dora", lgBattery, lgDisplay);

            arrayOfPhones[0] = nokiaN86;
            arrayOfPhones[1] = samsungS3;
            arrayOfPhones[2] = LGOptimus;

            foreach (var phone in arrayOfPhones)
            {
                Console.WriteLine(phone);
            }

            // Test the static field IPhone4S
            Console.WriteLine(GSM.IPhone4S.Manufacturer);
            Console.WriteLine(GSM.IPhone4S.Model);
            Console.WriteLine(GSM.IPhone4S.Price);

            Console.WriteLine();

            // Test Call History
            GSMCallHistoryTest callHistoryTest = new GSMCallHistoryTest(samsungS3);

            callHistoryTest.CallHistoryTest();
        }
Ejemplo n.º 24
0
 static GSM()
 {
     iPhone = new GSM("IPhone4S", "Apple",
                      new Battery(Battery.BatteryType.LiIon, "iBat", 600, 360), new Display(4, 256000),
                      "Iphone Owner", 750.30);
 }
 public GSMCallHistoryTest(GSM phone)
 {
     this.phone = phone;
 }
Ejemplo n.º 26
0
 //Problem 2. -> constructor
 static GSM()
 {
     iPhone4S = new GSM("IPhone 4S", "Apple", 1300.00m, "Telenor",
                        new Battery("Apple", 8, 200, Battery.BatType.LiPo),
                        new Display(960, 640, 16000000));
 }
Ejemplo n.º 27
0
 static GSM()
 {
     iPhone4S = new GSM("iPhone4S", "Apple", 700m, null,
         new Battery("AppleBattery", new TimeSpan(30, 27, 0), new TimeSpan(16, 22, 0),
         BatteryType.LiIon), new Display(4.1m, "16M"));
 }