Ejemplo n.º 1
0
        public static void Main()
        {
            Battery bl5c      = new Battery("BL-5C", 300, 33, BatteryType.NiMH);
            GSM     nokia1100 = new GSM("1100", "NOKIA", 100, "Ivan Ivanov", bl5c, 1.3f);

            Console.WriteLine(nokia1100);

            GSM galayA5 = new GSM("Galaxy A5", "Samsung", 779.90f, "Penka Petkova", new Battery("2300mAh integrated", 100, 2300, BatteryType.LiPol), 4.5f);

            Console.WriteLine(galayA5);

            Battery iPhoneBat = new Battery("iPhone bat", 200, 2000, BatteryType.LiIon);
            GSM     iPhone    = new GSM("iPhone4S", "Apple", 1000f, "Happy Iphone Owner", iPhoneBat, 3.5f);

            Console.WriteLine(iPhone);
            GSM  lgA390 = new GSM("A390-Dual SIM", "LG", 115, "Kirov", new Battery("1700 mAh", 800, 1700, BatteryType.LiIon), 2.1f);
            Call call1  = new Call("10.10.14", "10:05", "088812346", 18);
            Call cal2   = new Call(DateTime.Now, "0899999999", 150);
            Call cal3   = new Call();

            lgA390.AddCall(call1);
            lgA390.AddCall(cal2);
            lgA390.AddCall(cal3);
            Console.WriteLine(lgA390);
            Console.WriteLine(lgA390.CalcCallsPrice(0.37f));

            //new GSM(" ", " ");
            //call1.CallTime = null;
            //bl5c.Capacity = -1;
            //iPhone.DisplaySize = -1;
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            Battery bl5c = new Battery("BL-5C", 300, 33, BatteryType.NiMH);
            GSM nokia1100 = new GSM("1100", "NOKIA", 100, "Ivan Ivanov", bl5c, 1.3f);
            Console.WriteLine(nokia1100);

            GSM galayA5 = new GSM("Galaxy A5", "Samsung", 779.90f, "Penka Petkova", new Battery("2300mAh integrated", 100, 2300, BatteryType.LiPol), 4.5f);
            Console.WriteLine(galayA5);

            Battery iPhoneBat = new Battery("iPhone bat", 200, 2000, BatteryType.LiIon);
            GSM iPhone = new GSM("iPhone4S", "Apple", 1000f, "Happy Iphone Owner", iPhoneBat, 3.5f);
            Console.WriteLine(iPhone);
            GSM lgA390 = new GSM("A390-Dual SIM", "LG", 115, "Kirov", new Battery("1700 mAh", 800, 1700, BatteryType.LiIon), 2.1f);
            Call call1 = new Call("10.10.14", "10:05", "088812346", 18);
            Call cal2 = new Call(DateTime.Now, "0899999999", 150);
            Call cal3 = new Call();
            lgA390.AddCall(call1);
            lgA390.AddCall(cal2);
            lgA390.AddCall(cal3);
            Console.WriteLine(lgA390);
            Console.WriteLine(lgA390.CalcCallsPrice(0.37f));

            //new GSM(" ", " ");
            //call1.CallTime = null;
            //bl5c.Capacity = -1;
            //iPhone.DisplaySize = -1;
        }
Ejemplo n.º 3
0
        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("En-GB");

            GSM applePhone = new GSM(
                "iPhone 6s",
                "Apple",
                599.99m,
                "Ivan Petrov",
                new Battery("Non-removable Apple Battery", 240, 14, BatteryType.Li_Po),
                new Display(4.7, 16000000));

            GSM samsungPhone = new GSM(
                "Galaxy 7",
                "Samsung",
                569.99m,
                "Stamat Stamatov",
                new Battery("Non-removable Samsung Battery", 200, 14, BatteryType.Li_Ion),
                new Display(5.1, 16000000));

            GSM huaweiPhone = new GSM(
                "Honor V8",
                "Huawei",
                269.99m,
                "Stefan Georgiev",
                new Battery("Huawei Battery", 200, 14, BatteryType.NiCd),
                new Display(5.7, 15000000));

            GSM[] phones = { applePhone, samsungPhone, huaweiPhone };

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

            Console.WriteLine(GSM.IPhone4S);

            Console.WriteLine();
            Call callOne   = new Call(new DateTime(2016, 12, 31, 4, 32, 10), "0899 753 123", 60);
            Call callTwo   = new Call(new DateTime(2015, 02, 12, 14, 12, 43), "0894 771 423", 120);
            Call callThree = new Call(new DateTime(2016, 5, 3, 11, 38, 00), "0878 333 623", 30);

            applePhone.AddCall(callOne);
            applePhone.AddCall(callTwo);
            applePhone.AddCall(callThree);

            Console.WriteLine(applePhone.PrintCallHistory());
            Console.WriteLine();
            Console.WriteLine("Total price: {0:0.00} USD", applePhone.CalculateTotalPrice());

            applePhone.DeleteCall(callTwo);
            Console.WriteLine();
            Console.WriteLine("Total price without the longest call: {0:0.00} USD", applePhone.CalculateTotalPrice());

            Console.WriteLine();
            applePhone.ClearHistory();
            Console.WriteLine(applePhone.PrintCallHistory());
        }
Ejemplo n.º 4
0
 public void GSMCalls_ShouldStoreZeroCallsAndCalculatePrice0()
 {
     Battery battery=new Battery("BL-5C", 200, 1700, BatteryType.LiIon);
     GSM phone = new GSM("Samsung", "Galaxy 4", 550.34f, "Dimitar", battery, 5.0f);
     phone.AddCall(new Call());
     var result = phone.CalcCallsPrice(1.0f);
     float expected = 0.0f;
     Assert.AreEqual(expected, result, "Zero call should have price 0");
 }
Ejemplo n.º 5
0
        public void MyTestMethod()
        {
            Battery battery = new Battery("BL-5C", 200, 1700, BatteryType.LiIon);
            GSM phone = new GSM("Nokia", "1100", 100f, "Dimitar", battery, 1.5f);
            float callPrice = 2f;
            float expected = 0f;
            CallsGenerator calls=new CallsGenerator();
            for (int i = 0; i < calls.Calls.Length ; i++)
            {
                phone.AddCall(calls.Calls[i]);
                expected += calls.Calls[i].CallDuration / 60f;
            }

            expected *= callPrice;
            float result = phone.CalcCallsPrice(callPrice);
            Assert.AreEqual(expected, result, "All calls price should be correct "+expected);
        }