コード例 #1
0
        public static void CallHistoryTest()
        {
            //Create an instance of the GSM class.
            GSM myGsm = GSM.IPhone4S;

            //Add few calls.
            Call someCall = new Call(DateTime.Now, 120, "+359888888888");
            myGsm.AddCall(someCall);
            myGsm.AddCall(someCall);
            myGsm.DeleteCall(someCall);
            myGsm.AddCall(someCall);
            myGsm.AddCall(new Call(new DateTime(2013, 2, 10, 21, 14, 29), 1000, "0885088508"));
            myGsm.AddCall(new Call(new DateTime(2013, 1, 20, 11, 11, 11), 1000, "0885088508"));
            myGsm.AddCall(new Call(DateTime.Now, 119, "+359887121314"));

            //Display the information about the calls.
            Console.WriteLine("All calls:");
            myGsm.PrintAllCalls();

            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            PrintCallPrice(myGsm);

            //Remove the longest call from the historyand calculate the total price again.
            myGsm.RemoveLongestDurationCall();
            Console.WriteLine("\nAfter remove of longest duration call...");
            PrintCallPrice(myGsm);

            //Finally clear the call history and print it.
            myGsm.ClearCallHistory();
            Console.WriteLine("\nAfter clear...");
            myGsm.PrintAllCalls();
            PrintCallPrice(myGsm);
        }
コード例 #2
0
ファイル: GSM.cs プロジェクト: vaster/Telerik.vasko
        static public void AddCall()
        {

            Call thisCall = new Call();
            string anotherCall = null;
            Console.WriteLine();
            Console.WriteLine("You're in mode: Add Call");
            Console.WriteLine();
            Console.Write("Enter Date of the call:");
            thisCall.Date = Console.ReadLine();
            Console.Write("Enter the time when the call was made:");
            thisCall.Time = Console.ReadLine();
            Console.Write("Enter Phone number of the call reciver:");
            thisCall.DialedNumber = Console.ReadLine();
            Console.Write("Enter duration of the call(in seconds):");
            thisCall.Duration = int.Parse(Console.ReadLine());
            if (max < thisCall.Duration)
            {
                max = thisCall.Duration;
                indexOfLongestCall++;  //use this index to dell the longest call later in the 'RemoveCall' method

            }
            thisCall = new Call(thisCall.Date, thisCall.Time, thisCall.DialedNumber, thisCall.Duration);//invoke full argument constructor of class 'Call'
            CallHistory.Add(thisCall);//add the call in List<Call>
            Console.WriteLine();
            Console.Write("Add another call? Type 'yes' to proceed('no' for exit): ");
            anotherCall = Console.ReadLine().ToLower();
            if (anotherCall.Equals("yes"))
            {
                //Bill();
                GSM.AddCall();
            }

        }
コード例 #3
0
        public static void AddCalls(GSM gsm)
        {
            Call[] callArray = new Call[3];
            callArray[0] = new Call(DateTime.Now, "0889123456", 5);
            callArray[1] = new Call(DateTime.Now, "0889123455", 12);
            callArray[2] = new Call(DateTime.Now, "0878536897", 3);

            for (int index = 0; index < callArray.Length; index++)
            {
                gsm.AddCall(callArray[index]);
            }
        }
コード例 #4
0
ファイル: GSMCallHistoryTest.cs プロジェクト: AYankova/CSharp
        public static void RemoveLongestCall()
        {
            Call longestCall = new Call(DateTime.Now, "0", 0);

            for (int i = 0; i < testCalls.Length; i++)
            {
                if (testCalls[i].Duration >= longestCall.Duration)
                {
                    longestCall = testCalls[i];
                }
            }

            testGSM.DeleteCalls(longestCall);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            //zad.7
            GSMTest.PrintInfo();

            //Create an instance of the GSM class.
            GSM myPhone = new GSM("N95", "Nokia");

            //Add few calls.
            Call call = new Call(DateTime.Now, "0883333333", 60);
            Call nextCall = new Call(new DateTime(2013,02,10,20,34,20), "+3592376541212", 120);
            myPhone.AddCall(call);
            myPhone.AddCall(nextCall);

            //Display the information about the calls.
            foreach (var c in myPhone.CallHistory)
            {
                Console.WriteLine(c);
            }

            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            Console.Write("The total price of the calls is: ");
            myPhone.PriceOfCalls(0.37m);

            //Remove the longest call from the history and calculate the total price again.
            Call longest = new Call();
            longest.Duration = 0;
            for (int i = 0; i < myPhone.CallHistory.Count; i++)
            {
                if (myPhone.CallHistory[i].Duration > longest.Duration)
                {
                    longest = myPhone.CallHistory[i];
                }
            }
            myPhone.RemoveCall(longest);
            Console.Write("The new price after removing longest call is: ");
            myPhone.PriceOfCalls(0.37m);

            //Finally clear the call history and print it.
            myPhone.ClearCallHistory();
            foreach (var c in myPhone.CallHistory)
            {
                Console.WriteLine(c);
            }
        }
コード例 #6
0
        public void Test()
        {
            GSM iPhone = GSM.IPhone4S;

            //Add Calls
            Call newCaller = new Call("10.02.2012", "17:00", "0886254882", 600);
            Call newCaller2 = new Call("11.12.2012", "17:00", "0886254882", 2500);
            Call newCaller3 = new Call("08.08.2012", "18:00", "0886254882", 600);
            iPhone.AddCall(newCaller);
            iPhone.AddCall(newCaller2);
            iPhone.AddCall(newCaller3);

            //Print CallHistory
            StringBuilder testOutput = new StringBuilder();
            foreach (var call in iPhone.CallHistory)
            {
                string callStr = call.ToString();
                testOutput.Append(callStr);
                testOutput.Append("\n\r");
            }
            Console.WriteLine(testOutput.ToString());

            //Calculate Price
            decimal price = iPhone.CalculatePrice(0.37m);
            Console.WriteLine("{0:F2}лв.", price);

            //Remove one Call from CallHistory
            iPhone.RemoveCall(1);
            testOutput.Remove(0, testOutput.Length);
            foreach (var call in iPhone.CallHistory)
            {
                string callStr = call.ToString();
                testOutput.Append(callStr);
                testOutput.Append("\n\r");
            }
            Console.WriteLine(testOutput.ToString());

            //Calculate New Price
            price = iPhone.CalculatePrice(0.37m);
            Console.WriteLine("{0:F2}лв.", price);

            //Clear CallHistory
            iPhone.EmptyCallHistory();
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: damy90/Telerik-all
        static void Main(string[] args)
        {
            var ipPhone6 = new GSM(model: "IP-Phone6", manufacturer: "xApple");
            var salamSumng = new GSM(model: "Jalacxy7", manufacturer: "SalamSung");

            var listFromSmartPhones = new List<GSM>();
            listFromSmartPhones.Add(ipPhone6);
            listFromSmartPhones.Add(salamSumng);

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

            var iPhone4s = GSM.IPhone4s;


            var firstTestCall = new Call()
            {
                TimeStart = DateTime.Now,
                TimeEnd = DateTime.Now.AddMinutes(2),
                ItsIncomming = false,
                PhoneNumber = "0043123123"
            };

            var duration = firstTestCall.Duration();

            var secondTestCall = new Call()
            {
                TimeStart = DateTime.Now,
                TimeEnd = DateTime.Now.AddMinutes(3),
                ItsIncomming = false,
                PhoneNumber = "0043123123"
            };

            ipPhone6.AddCall(firstTestCall);
            ipPhone6.AddCall(secondTestCall);

            decimal pricePerMinute = 0.37M;
            var totalPrice = ipPhone6.CallPrice(pricePerMinute);

            Console.WriteLine("Total call price: " + totalPrice);
        }
コード例 #8
0
        public void AddCall()
        {
            Call addCall = new Call();

            this.callHistory.Add(addCall);
        }
コード例 #9
0
ファイル: GSM.cs プロジェクト: reddogyy/TelerikAcademy
 public void AddCall(Call call)
 {
     List<Call> tempCallHistory = new List<Call>(this.CallHistory);
     tempCallHistory.Add(call);
     this.CallHistory = tempCallHistory;
 }
コード例 #10
0
ファイル: GSM.cs プロジェクト: antonpopov/TelerikAcademy
 public void ClearCallHistory(Call call)
 {
     this.calls.Clear();
 }
コード例 #11
0
ファイル: GSM.cs プロジェクト: EvgeniVelikov92/TelerikAcademy
 public void RemoveCall(Call call)
 {
     for (int i = 0; i < callHistory.Count; i++)
     {
         if (call.Duration == callHistory[i].Duration)
         {
             callHistory.RemoveAt(i);
         }
     }
 }
コード例 #12
0
ファイル: GSM.cs プロジェクト: nnaidenov/TelerikAcademy
 //Add CallHistory
 public void AddCall(Call newCall)
 {
     if (callHistory == null)
     {
         callHistory = new List<Call>();
         callHistory.Add(newCall);
     }
     else
     {
         callHistory.Add(newCall);
     }
 }
コード例 #13
0
ファイル: GSM.cs プロジェクト: huoxudong125/TelerikAcademy
 public int DeleteCallFromHistory(Call call)
 {
     if (call == null)
     {
         throw new ArgumentNullException(@"Trying to delete ""null"" call.");
     }
     for (int i = 0; i < callHistory.Count; i++)
     {
         if (callHistory[i].Date == call.Date &&
             callHistory[i].Time == call.Time &&
             callHistory[i].DailedPhone == call.DailedPhone)
         {
             callHistory.RemoveAt(i);
             return 1;
         }
     }
     return -1;
 }
コード例 #14
0
ファイル: GSM.cs プロジェクト: damy90/Telerik-all
 public Call DelleteCall(Call call)
 {
     this.callHistory.Remove(call);
     return call;
 }
コード例 #15
0
ファイル: GSM.cs プロジェクト: MarKamenov/TelerikAcademy
        /// <summary>
        /// Closes a call - ends the last opened call from the call list.
        /// </summary>
        public void CloseCall(int durationSeconds = -1)
        {
            if (this.currentCall == null)
            {
                throw new ApplicationException("No call to close!");
            }

            if (durationSeconds < 0)
            {
                this.currentCall.EndCall(); // Will calculate the duration by the system clock
            }
            else
            {
                this.currentCall.EndCall(durationSeconds);
            }

            Call newCall = new Call(this.currentCall); // Copy the current call
            this.callHistory.Add(newCall); // ... and add it to the call history
            this.currentCall = null; // ... release the current call
        }
コード例 #16
0
ファイル: GSM.cs プロジェクト: diagara/Telerik-Academy
 public void RemoveCall(Call call)
 {
     this.CallHistory.Remove(call);
 }
コード例 #17
0
 public void Remove(Call call)
 {
     this.performedCalls.Remove(call);
 }
コード例 #18
0
 public void Add(Call call)
 {
     performedCalls.Add(call);
 }
コード例 #19
0
ファイル: Gsm.cs プロジェクト: deyantodorov/TelerikAcademy
 public void AddCall(Call newCall)
 {
     this.CallHistory.Add(newCall);
 }
コード例 #20
0
 public void AddCall(Call call)
 {
     this.CallHistoryAdder = call;
 }
コード例 #21
0
ファイル: GSM.cs プロジェクト: damy90/Telerik-all
 public Call AddCall(Call call)
 {
     this.callHistory.Add(call);
     return call;
 }
コード例 #22
0
ファイル: Gsm.cs プロジェクト: nikolaynikolov/Telerik
 public void AddCallToHistory(int year, int month, int day, int hour, int minute, string dialledNumber, int duration)
 {
     DateTime date = new DateTime(year, month, day, hour, minute, 0);
     Call call = new Call(date, dialledNumber, duration);
     this.callHistory.Add(call);
 }
コード例 #23
0
ファイル: GSM.cs プロジェクト: MarKamenov/TelerikAcademy
        /// <summary>
        /// Opens a new call - creates a new Call object with the dialed number and adds it to the call list.
        /// </summary>
        /// <param name="phoneNum">The dialed number</param>
        public void OpenCall(string phoneNum)
        {
            if (this.currentCall != null)
            {
                throw new ApplicationException("You can't open a new call before you close the old one!");
            }

            this.currentCall = new Call(phoneNum);
        }
コード例 #24
0
 public void Add(Call call)
 {
     performedCalls.Add(call);
 }
コード例 #25
0
ファイル: GSM.cs プロジェクト: EmilMitev/Telerik-Academy
 // Methods
 public void AddCalls(Call call)
 {
     this.HistoryCall.Add(call);
 }
コード例 #26
0
 public void Remove(Call call)
 {
     this.performedCalls.Remove(call);
 }
コード例 #27
0
ファイル: GSM.cs プロジェクト: huoxudong125/TelerikAcademy
 public void AddCalltoHistory(Call newCall)
 {
     if (newCall == null)
     {
         throw new ArgumentNullException(@"""null"" calls are not allowed!");
     }
     this.callHistory.Add(newCall);
 }
コード例 #28
0
ファイル: GSM.cs プロジェクト: RobinJS/dotNET
 public void AddCall()
 {
     Call addCall = new Call();
     this.callHistory.Add(addCall);
 }
コード例 #29
0
ファイル: GSM.cs プロジェクト: antonpopov/TelerikAcademy
 public void AddCall(Call call)
 {
     this.calls.Add(call);
 }
コード例 #30
0
 public void DeleteCall(Call call)
 {
     int index = callHistory.IndexOf(call);
     if (index != -1)
     {
         callHistory.RemoveAt(index);
     }
 }
コード例 #31
0
ファイル: GSM.cs プロジェクト: antonpopov/TelerikAcademy
 public void DeleteCall(Call call)
 {
     this.calls.Remove(call);
 }
コード例 #32
0
 public void DeleteCalls(Call data)
 {
     callHistory.Remove(data);
 }
コード例 #33
0
ファイル: GSM.cs プロジェクト: tzigy/TelerikAcademy
 public void DeleteCall(Call call)
 {
     this.callHistory.Remove(call);
 }
コード例 #34
0
 //=== Problem 10 ==> Add methods in the `GSM` class for adding and deleting calls from the calls history. Add a method to clear the call history.
 public void AddCall(Call call)
 {
     CallHistory.Add(call);
 }
コード例 #35
0
 public void AddCall(Call call)
 {
     this.callHistory.Add(call);
 }
コード例 #36
0
 public void AddCalls(Call data)
 {
     callHistory.Add(data);
 }