예제 #1
0
        static void Main()
        {
            GSM phone1 = new GSM();
            phone1.Price = 10;
            phone1.Owner = "az";

            GSM phone2 = new GSM();
            phone2.Price = 12;
            phone2.Manifacturer = "made in china";
            phone2.Model = "samsung 2";

            GSM phone3 = new GSM();
            phone3.Model = "nokia q";
            phone3.Owner = "pesho";
            phone3.Manifacturer = " made in china";

            GSM[] phones = new GSM[] { phone1, phone2, phone3 };
            foreach (GSM phone in phones)
            {
                phone.DisplayGsm();
                Console.WriteLine();
            }

            GSM.Iphone.DisplayGsm();

            Battery battery = new Battery(BatteryType.NiCd);
            Console.WriteLine(battery.Type);

            Call firstCall = new Call(DateTime.Now, 0987654321, 324);
            Call secondCall = new Call();
            secondCall.Number = 0999999;
            secondCall.Seconds = 433;
            GSM calls = new GSM("samsung", "china");

            //--------------
            //test call history
            //---------------
            calls.AddCall(DateTime.Now, 0987654321, 234);
            calls.AddCall(DateTime.Now, 1234567890, 342);
            calls.DeleteCall(DateTime.Now, 1234567890, 342);
            foreach (var call in calls.Callhistory)
            {
                Console.WriteLine("{0} {1} {2}", call.DateTime, call.Number, call.Seconds);
            }

            Console.WriteLine( calls.CallPrice(0.34) );
            calls.RemoveAllCalls();
            foreach (var call in calls.Callhistory)
            {
                Console.WriteLine("{0} {1} {2}", call.DateTime, call.Number, call.Seconds);
            }
        }
        public GSMCallHistoryTest()
        {
            //creating gsm
            GSM gsm = new GSM("Samsung", "A35");

            //creating some calls
            Console.WriteLine("Adding call with duration {0} minutes and {1} seconds", 20, 30);
            Call call1 = new Call(new DateTime(2012, 1, 22), new TimeSpan(0, 22, 30), "+35932423224");
            Console.WriteLine();
            Console.WriteLine("Adding call with duration {0} minutes and {1} seconds", 15, 11);
            Call call2 = new Call(new DateTime(2012, 1, 23), new TimeSpan(0, 15, 11), "+35932413324");
            Console.WriteLine();
            Console.WriteLine("Adding call with duration {0} minutes and {1} seconds", 7, 30);
            Call call3 = new Call(new DateTime(2012, 1, 24), new TimeSpan(0, 7, 30), "+3593243424");
            Console.WriteLine();

            Console.WriteLine("Adding calls to call history");
            Console.WriteLine();

            //adding calls to call history
            gsm.CallHistory.Add(call1);
            gsm.CallHistory.Add(call2);
            gsm.CallHistory.Add(call3);

            //calculating total price
            Console.WriteLine("Total call price:");

            Console.WriteLine(gsm.TotalCallsPrice(0.37M));
            Console.WriteLine();
            //finding longest call
            Call longestCall = (from e in gsm.CallHistory
                                orderby e.Duration descending
                                select e).First();

            //removing longest call

            gsm.CallHistory.Remove(longestCall);

            //calculating price again
            Console.WriteLine("Total call price after longest call has been removed:");

            Console.WriteLine(gsm.TotalCallsPrice(0.37M));
            //clearing history
            Console.WriteLine("History cleared!");
            Console.WriteLine();
            gsm.ClearCallsHistory();
        }
예제 #3
0
 public void AddCall(DateTime dateTime, int number, int seconds)
 {
     Call call= new Call(dateTime, number, seconds);
     callHistory.Add(call);
 }
예제 #4
0
 public bool RemoveCall(Call call)
 {
     return CallHistory.Remove(call);
 }
예제 #5
0
            public GSMCallHistoryTest()
            {
                GSM gsm = new GSM("Galaxy S2", "Samsung");

                Call call1 = new Call(new DateTime(2012, 1, 22), new TimeSpan(0, 22, 30), "+35932423224");
                Call call2 = new Call(new DateTime(2012, 1, 23), new TimeSpan(0, 15, 11), "+35932413324");
                Call call3 = new Call(new DateTime(2012, 1, 24), new TimeSpan(0, 7, 30), "+3593243424");

                List<Call> callHistory = new List<Call>();
                callHistory.Add(call1);
                callHistory.Add(call2);
                callHistory.Add(call3);

                gsm.CallHistory = callHistory;

                Console.WriteLine(gsm.TotalCallsPrice(0.37M));

                //TODO:
                //Remove the longest call from the history and calculate the total price again.

                gsm.ClearCallsHistory();
            }
예제 #6
0
 public void AddCall(Call call)
 {
     CallHistory.Add(call);
 }
예제 #7
0
 // Remove call from the call history
 public void RemoveCall(Call call)
 {
     this.CallHistory.Remove(call);
 }
예제 #8
0
 public void DeleteCall(Call call)
 {
     this.callHistory.Remove(call);
 }
예제 #9
0
        public void AddCall(string phoneNumber, DateTime date, TimeSpan duration)
        {
            Call call = new Call(phoneNumber, date, duration);

            this.callHistory.Add(call);
        }
예제 #10
0
 public void AddCall(Call call)
 {
     this.callHistory.Add(call);
 }