Ejemplo n.º 1
0
        public static void TestedGSM()
        {
            ClassGSM Nokia = new ClassGSM("6303i classic", "Nokia", 50,"One Favorite", new Battery(BatteryType.Li_Ion, "BL-5CT", 515, 8), new Display(2.2, 16*1000*1000));
            ClassGSM Panasonic = new ClassGSM("VS3", "Panasonic", 35,"Another Favorite", new Battery(BatteryType.Li_Ion, "Standart", 210, 4.5), new Display(2.3, 16*1000*1000));
            ClassGSM Nexus = new ClassGSM("6", "Motorola", 1040, "Some ONe", new Battery(BatteryType.LiPo, "Non-removable", 330, 24), new Display(5.96, 16*1000*1000));

            ClassGSM[] gsmArray = new ClassGSM[] {Nokia, Panasonic, Nexus};

            var size = gsmArray.Length;
            var builder = new StringBuilder();

            for (int i = 0; i < size; i++)
            {
                //Console.WriteLine(gsmArray[i]);
                //Console.WriteLine(new string('*', 25));

                builder.AppendLine(gsmArray[i].ToString());
                builder.AppendLine(new string('*', 25));

            }

            builder.AppendLine(ClassGSM.IPhone4S.ToString());

            Console.WriteLine(builder.ToString());
        }
Ejemplo n.º 2
0
 private static void PrintCallHistory(ClassGSM phone)
 {
     Console.WriteLine("Call History:");
     foreach (var item in phone.callHistory)
     {
         Console.WriteLine(item);
     }
     Console.WriteLine();
 }
Ejemplo n.º 3
0
 private static void FindLongestCall(ClassGSM phone, ref int bestCall, ref Call longestCall)
 {
     foreach (var item in phone.callHistory)
     {
         if (bestCall < item.Duration.TotalSeconds)
         {
             bestCall = (int)item.Duration.TotalSeconds;
             longestCall = item;
         }
     }
 }
Ejemplo n.º 4
0
        public static void TestCalls()
        {
            ClassGSM phone = new ClassGSM("N97Mini", "Nokia", 199.98, "SomeOne", new Battery(BatteryType.NiMH, "standart"), new Display(4.5));
            Call currentCall = new Call(DateTime.Now.AddDays(1), "0887654321", 58);
            phone.AddCall(currentCall);

            currentCall = new Call(DateTime.Now.AddMinutes(24D), "0887654321", 258);
            phone.AddCall(currentCall);

            currentCall = new Call(DateTime.Now.AddDays(3), "0887654321", 155);
            phone.AddCall(currentCall);

            PrintCallHistory(phone);
            // > end Call History

            // > price
            Console.WriteLine("Total cost: {0}EU", phone.TotalCostCalls());
            Console.WriteLine("[price of every started minutes is {0} EU/min]", ClassGSM.pricePM);
            Console.WriteLine();

            // > longest call
            int bestCall = -1;
            Call longestCall = new Call("000", 0);

            FindLongestCall(phone, ref bestCall, ref longestCall);
                // > > deleted
            phone.DeleteCall(longestCall);
            Console.WriteLine("The longest call is {0} seconds", bestCall);
            Console.WriteLine(longestCall.ToString());
            Console.WriteLine();
            Console.WriteLine("- TOTAL COST -");
            Console.WriteLine("Total cost: {0}EU", phone.TotalCostCalls());

            Console.WriteLine();
            PrintCallHistory(phone);
        }