Ejemplo n.º 1
0
        static void Main()
        {
            Console.WriteLine(new string('=', 17) + "\r\nGSM class example\r\n" + new string('=', 17));
            GSM stupidGsm = new GSM("Galaxy Kles3", "Gnusmas", 700, "Acho");
            string gsmInfo = stupidGsm.ToString();
            Console.WriteLine(gsmInfo);

            Console.WriteLine(new string('=', 21) + "\r\nDisplay class example\r\n" + new string('=', 21));
            Display newDisplay = new Display(5.2, 16000000);
            Console.WriteLine("Display size: {0} inches\r\nDisplay colors: {1}", newDisplay.Size, newDisplay.NumberOfColors);

            Console.WriteLine(new string('=', 21) + "\r\nBattery class example\r\n" + new string('=', 21));
            Battery newBattery = new Battery(BatteryType.LiIon, 700, 600);
            Console.WriteLine("Battery model: {0}\r\nHours Idle: {1}\r\nHours Talk: {2}", newBattery.Model, newBattery.HoursIdle, newBattery.HoursTalk);

            Console.WriteLine(new string('=', 39) + "\r\nCall histroy and price of calls example\r\n" + new string('=', 39));
            GSM anotherTest = new GSM();
            anotherTest.AddCall(new Calls(new DateTime(2015, 3, 17), "+359873876678", 100));
            Console.WriteLine(anotherTest.CallHistory[0]);
            Console.WriteLine("Total price of calls: {0:F2}", anotherTest.TotalPriceOfCalls());

            Console.WriteLine(new string('=', 31) + "\r\nCall history test class example\r\n" + new string('=', 31));
            CallHistoryTest testHistrory = new CallHistoryTest();
            testHistrory.TestTheCallHistory();

            Console.WriteLine(new string('=', 22) + "\r\nGSM test class example\r\n" + new string('=', 22));
            GsmTest fewGsms = new GsmTest();
            fewGsms.CreateAFewGSMs(2);
        }
        public void TestTheCallHistory()
        {
            GSM testCallHistory = new GSM();

            testCallHistory.AddCall(new Calls(new DateTime(2015, 03, 17), "+359876642834", 80));
            testCallHistory.AddCall(new Calls(new DateTime(2015, 03, 15), "+359886349830", 32));
            testCallHistory.AddCall(new Calls(new DateTime(2015, 03, 15), "+359895543831", 90));
            testCallHistory.AddCall(new Calls(new DateTime(2015, 03, 14), "+359879402535", 150));
            testCallHistory.AddCall(new Calls(new DateTime(2015, 03, 13), "+359883145884", 120));

            foreach (var call in testCallHistory.CallHistory)
            {
                Console.WriteLine(call);
            }

            Console.WriteLine();

            Console.WriteLine("Total price of calls: {0:F2}", testCallHistory.TotalPriceOfCalls());

            int longestCall = 0;
            foreach (var call in testCallHistory.CallHistory)
            {
                if (call.Duration > longestCall)
                {
                    longestCall = call.Duration;
                }
            }

            testCallHistory.DeleteCall(longestCall);

            Console.WriteLine("Total price of calls after removing the longest call: {0:F2}", testCallHistory.TotalPriceOfCalls());
            testCallHistory.ClearCalls();
        }
Ejemplo n.º 3
0
        public void TestTheCallHistory()
        {
            GSM testCallHistory = new GSM();

            testCallHistory.AddCall(new Calls(new DateTime(2015, 03, 17), "+359876642834", 80));
            testCallHistory.AddCall(new Calls(new DateTime(2015, 03, 15), "+359886349830", 32));
            testCallHistory.AddCall(new Calls(new DateTime(2015, 03, 15), "+359895543831", 90));
            testCallHistory.AddCall(new Calls(new DateTime(2015, 03, 14), "+359879402535", 150));
            testCallHistory.AddCall(new Calls(new DateTime(2015, 03, 13), "+359883145884", 120));

            foreach (var call in testCallHistory.CallHistory)
            {
                Console.WriteLine(call);
            }

            Console.WriteLine();

            Console.WriteLine("Total price of calls: {0:F2}", testCallHistory.TotalPriceOfCalls());

            int longestCall = 0;

            foreach (var call in testCallHistory.CallHistory)
            {
                if (call.Duration > longestCall)
                {
                    longestCall = call.Duration;
                }
            }

            testCallHistory.DeleteCall(longestCall);

            Console.WriteLine("Total price of calls after removing the longest call: {0:F2}", testCallHistory.TotalPriceOfCalls());
            testCallHistory.ClearCalls();
        }
Ejemplo n.º 4
0
        static void Main()
        {
            Console.WriteLine(new string('=', 17) + "\r\nGSM class example\r\n" + new string('=', 17));
            GSM    stupidGsm = new GSM("Galaxy Kles3", "Gnusmas", 700, "Acho");
            string gsmInfo   = stupidGsm.ToString();

            Console.WriteLine(gsmInfo);

            Console.WriteLine(new string('=', 21) + "\r\nDisplay class example\r\n" + new string('=', 21));
            Display newDisplay = new Display(5.2, 16000000);

            Console.WriteLine("Display size: {0} inches\r\nDisplay colors: {1}", newDisplay.Size, newDisplay.NumberOfColors);

            Console.WriteLine(new string('=', 21) + "\r\nBattery class example\r\n" + new string('=', 21));
            Battery newBattery = new Battery(BatteryType.LiIon, 700, 600);

            Console.WriteLine("Battery model: {0}\r\nHours Idle: {1}\r\nHours Talk: {2}", newBattery.Model, newBattery.HoursIdle, newBattery.HoursTalk);

            Console.WriteLine(new string('=', 39) + "\r\nCall histroy and price of calls example\r\n" + new string('=', 39));
            GSM anotherTest = new GSM();

            anotherTest.AddCall(new Calls(new DateTime(2015, 3, 17), "+359873876678", 100));
            Console.WriteLine(anotherTest.CallHistory[0]);
            Console.WriteLine("Total price of calls: {0:F2}", anotherTest.TotalPriceOfCalls());

            Console.WriteLine(new string('=', 31) + "\r\nCall history test class example\r\n" + new string('=', 31));
            CallHistoryTest testHistrory = new CallHistoryTest();

            testHistrory.TestTheCallHistory();

            Console.WriteLine(new string('=', 22) + "\r\nGSM test class example\r\n" + new string('=', 22));
            GsmTest fewGsms = new GsmTest();

            fewGsms.CreateAFewGSMs(2);
        }
Ejemplo n.º 5
0
 public void CreateAFewGSMs(int numOfGsms)
 {
     GSM[] someGsms = new GSM[numOfGsms];
     for (int i = 0; i < numOfGsms; i++)
     {
         someGsms[i] = new GSM();
         Console.Write("Enter model for GSM number {0}: ", i + 1);
         someGsms[i].Model = Console.ReadLine();
         Console.Write("Enter manufacturer for GSM number {0}: ", i + 1);
         someGsms[i].Manufacturer = Console.ReadLine();
         Console.Write("Enter owner for GSM number {0}: ", i + 1);
         someGsms[i].Owner = Console.ReadLine();
         Console.Write("Enter price for GSM number {0}: ", i + 1);
         someGsms[i].Price = double.Parse(Console.ReadLine());
     }
     foreach (var gsm in someGsms)
     {
         Console.WriteLine("Model: {0}\r\nManufacturer: {1}\r\nOwner: {2}\r\nPrice: {3}", gsm.Model, gsm.Manufacturer, gsm.Owner, gsm.Price);
     }
     GSM iPhoneInfo = new GSM();
     Console.WriteLine(iPhoneInfo.IPhone4SInfo);
 }
Ejemplo n.º 6
0
        public void CreateAFewGSMs(int numOfGsms)
        {
            GSM[] someGsms = new GSM[numOfGsms];
            for (int i = 0; i < numOfGsms; i++)
            {
                someGsms[i] = new GSM();
                Console.Write("Enter model for GSM number {0}: ", i + 1);
                someGsms[i].Model = Console.ReadLine();
                Console.Write("Enter manufacturer for GSM number {0}: ", i + 1);
                someGsms[i].Manufacturer = Console.ReadLine();
                Console.Write("Enter owner for GSM number {0}: ", i + 1);
                someGsms[i].Owner = Console.ReadLine();
                Console.Write("Enter price for GSM number {0}: ", i + 1);
                someGsms[i].Price = double.Parse(Console.ReadLine());
            }
            foreach (var gsm in someGsms)
            {
                Console.WriteLine("Model: {0}\r\nManufacturer: {1}\r\nOwner: {2}\r\nPrice: {3}", gsm.Model, gsm.Manufacturer, gsm.Owner, gsm.Price);
            }
            GSM iPhoneInfo = new GSM();

            Console.WriteLine(iPhoneInfo.IPhone4SInfo);
        }