Beispiel #1
0
        static void Main(string[] args)
        {
            DateTime date1 = DateTime.Now;

            GSM newGsmCall = new GSM();
            newGsmCall.CallHistory.Add(new Call(date1, 0878547866, 180, "Kiril"));     //adding calls from the calls history
            newGsmCall.CallHistory.Add(new Call(date1, 0878256567, 120, "Tosho"));
            newGsmCall.CallHistory.Add(new Call(date1, 0898321455, 120, "Ogi"));
            newGsmCall.CallHistory.Add(new Call(date1, 0878547866, 240, "Kiril"));

            foreach (Call call in newGsmCall.CallHistory)
            {
                Console.WriteLine("Name: " + call.Name);
                Console.WriteLine("Number: " + call.Number);
                Console.WriteLine("Date: " + call.Date);
                Console.WriteLine("Duration in seconds: " + call.Duration);
                Console.WriteLine();
            }

             //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            Console.WriteLine("Total price: " + newGsmCall.CalculateTotalPrice(0.37m) + "$");

            newGsmCall.RemoveCallMaxValue();       // Remove the longest call from the history  and calculate the total price again.
            Console.WriteLine("Total price: " + newGsmCall.CalculateTotalPrice(0.37m) + "$");

            newGsmCall.ClearCallHistory(); //method to clear the call history.

            GSM newGsm = new GSM("Gogo", "Samsung", "S 222", 32323);
            Battery bateryInfo = new Battery("GG 33", 222, BatteryTypes.LiPol);
            Display Newdisplay = new Display("112x23",232323);
            Console.WriteLine(newGsm.ToString());
        }
Beispiel #2
0
        public GSM(string Owner, string Manufacturer, string Model, decimal Price)
        {
            if (Owner.Length < 20 && Owner.Length > 0)
            {
                this.owner = Owner;
            }
            else
            {
                throw new ArgumentException("The value must to be less of 20, and bigger of 0");
            }
            if (Manufacturer.Length < 10 && Manufacturer.Length > 0)
            {
                this.manufacturer = Manufacturer;
            }
            else
            {
                throw new ArgumentException("The value must to be less of 10, and bigger of 0");
            }

            this.model = Model;
            if (Price > 0)
            {
                this.price = Price;
            }
            else
            {
                throw new ArgumentException("The value not must to be less of null");
            }
            this.battery = new Battery();
            this.display = new Display();
        }