Beispiel #1
0
        static void Main()
        {
            Display someDisplay = new Display("4.5inch", "165Million");
            Battery someBattery = new Battery("Varta", 10.00, 10.00);

            GSM myPhone = new GSM("G3", "JIAYU", "Pencho", 390.00m, someBattery, someDisplay);

            myPhone.AddCallToHist(DateTime.Now, "088617555", 180);
            myPhone.AddCallToHist(DateTime.Now, "099953312", 2000);
            myPhone.AddCallToHist(DateTime.Now, "125989364", 369);
            myPhone.AddCallToHist(DateTime.Now, "058933153", 600);

            myPhone.DisplayCallHistory();
            Console.WriteLine("Price for all calls");
            //calculating totalPrice for all calls
            decimal pricePerMinute = 0.37m;
            decimal totalPrice = 0m;
            totalPrice=myPhone.TotalPriceCall(pricePerMinute);
            Console.WriteLine(totalPrice);

            //Remove LongestCall and calculating price again
            myPhone.RemoveLongestCall();
            Console.WriteLine("Price for all calls after removing the longest call");
            totalPrice = myPhone.TotalPriceCall(pricePerMinute);
            Console.WriteLine(totalPrice);
            myPhone.DisplayCallHistory();
            myPhone.ClearCallHistory();
            Console.WriteLine("This is cleared call history:");
            myPhone.DisplayCallHistory();
        }
Beispiel #2
0
        static void Main()
        {
            //the data is fake
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
            GSM[] gsms = new GSM[3];

            Display display1 = new Display(4F, "16M");
            Battery battery1 = new Battery(450, 30, BatteryType.NiCd);
            gsms[0] = new GSM("Nokia 808", "Nokia Corporation", 345.00M, "Petar Petrov", battery1, display1);

            Display display2 = new Display(2.5F, "256K");
            Battery battery2 = new Battery(950, 35, BatteryType.LiIon);
            gsms[1] = new GSM("Samsung Ace", "Samsung Group", 545.00M, "Ivan Ivanov", battery2, display2);

            Display display3 = new Display(5.1F, "16M");
            Battery battery3 = new Battery(700, 25, BatteryType.NiMH);
            gsms[2] = new GSM("Motorola", "Motorola Solutions, Inc.", 45.00M, "Vasil Vasilev", battery3, display3);

            foreach (var gsm in gsms)
            {
                Console.WriteLine(gsm.ToString());
                Console.WriteLine();
            }

            //Display the information about the static property IPhone4S.
            GSM.IPhone4S.Owner = "Alis";
            Console.WriteLine(GSM.IPhone4S.ToString());
        }
Beispiel #3
0
 // Constructors:
 public GSM(string model, string manufacturer, double? price, string owner, Battery battery, Display display)
 {
     this.Model = model;
     this.Manufacturer = manufacturer;
     this.Price = price;
     this.Owner = owner;
     this.Battery = battery;
     this.Display = display;
 }
Beispiel #4
0
 public GSM(string model, string manufact, decimal price, string owner, Display displayChar, Battery batteryChar)
 {
     this.model = model;
     this.manufacturer = manufact;
     this.price = price;
     this.owner = owner;
     this.displayCharacteristics = displayChar;
     this.batteryCharacteristics = batteryChar;
 }
Beispiel #5
0
 public GSM(string model, string manufacturer, decimal? price, string owner, Battery battery, Display display)
 {
     this.model = model;
     this.manufacturer = manufacturer;
     this.price = price;
     this.Owner = owner;
     this.battery = battery;
     this.Display = display;
 }
Beispiel #6
0
 public GSM(string model, string manufacturer, decimal? price, string owner, Battery battery)
     : this(manufacturer, model, price, owner, battery, null)
 {
     this.model = model;
     this.manufacturer = manufacturer;
     this.price = price;
     this.Owner = owner;
     this.battery = battery;
 }
Beispiel #7
0
Datei: GSM.cs Projekt: kicata/OPP
 //constructors full
 public GSM(string phoneModel, string manifacturer,string owner, decimal price, Battery battery, Display display)
 {
     this.phoneModel = phoneModel;
     this.manifacturer = manifacturer;
     this.owner = owner;
     this.price = price;
     this.battery= new Battery();
     this.display = new Display();
 }
Beispiel #8
0
 public GSM(string model, string manufacturer, decimal? price = 0.0m,
     string owner = null, Battery battery = null, Display display = null)
 {
     this.Model = model;
     this.Manufacturer = manufacturer;
     this.Price = price;
     this.Owner = owner;
     this.battery = battery;
     this.display = display;
 }
 //Mandatory Fields Constructor (Task 2.)
 public GSM(string userModel, string userManufacturer, float userPrice = 0, string userOwner = null
     , Battery userBattery = null, Display userDisplay = null)
 {
     this.model = userModel;
     this.manufacturer = userManufacturer;
     this.Price = userPrice; //Calls for the property of the field "price"
     this.owner = userOwner;
     this.instBattery = userBattery;
     this.instDisplay = userDisplay;
     this.callHistory = new List<Call>();
 }
Beispiel #10
0
        static void Main(string[] args)
        {
            //Create an array of few instances of the GSM class.
            GSM[] gsmArray = new GSM[3];
            Display display = new Display(4.8, 16000000);
            Battery battery = new Battery("NiMH", 30.7, 6.7);
            battery.batteryType = BatteryType.NiMH;

            //initialize the phones
            gsmArray[0] = new GSM("Galaxy SIII", "Samsung", 870, "Samuel L. Jackson", battery, display);
            gsmArray[1] = new GSM("Milestone 2", "Motorola", 300, "Garry Barlow", battery, display);
            gsmArray[2] = new GSM("Sony", "Xperia 8", 220, "Zigs Gugenheim", battery, display);

            //Display the information about the GSMs in the array.
            for (int i = 0; i < gsmArray.Length; i++)
            {
                Console.WriteLine(gsmArray[i]);
            }

            //Display the information about the static property IPhone4S
            Console.WriteLine(GSM.IPhone4S);
        }
Beispiel #11
0
 public GSM(string model, string manufacturer, double? price, Battery battery)
     : this(model, manufacturer, price, null, battery, null)
 {
 }
Beispiel #12
0
 //Problem 2. Define several constructors for the defined classes that take different sets of arguments
 //(the full information for the class or part of it).
 //Assume that model and manufacturer are mandatory (the others are optional). All unknown data fill with null.
 #region Constructors
 public GSM(string model, string manufacturer, decimal?price, string owner, Display display, Battery battery)
 {
     this.Model        = model;
     this.Manufacturer = manufacturer;
     this.Price        = price;
     this.Owner        = owner;
     this.Display      = display;
     this.Battery      = battery;
     this.CallHistory  = new List <Call>();
 }
Beispiel #13
0
 //Problem 4. ToString
 //Add a method in the GSM class for displaying all information about it. Try to override ToString().
 #region Methods
 public override string ToString()
 {
     return(string.Format(CultureInfo.CreateSpecificCulture("en-US"), "[Model: {0}; Manufacturer: {1}; Price: {2:C}; Owner: {3}; Battery: {4}; Display: {5}]",
                          Model, Manufacturer, Price, Owner, Battery.ToString(), Display.ToString()));
 }
Beispiel #14
0
 public Gsm(string gsmManufacturer, string gsmModel, string gsmOwner, int gsmPrice, Battery gsmBattery, Display gsmDisplay)
     : this(gsmManufacturer, gsmModel)
 {
     this.Owner        = gsmOwner;
     this.Price        = gsmPrice;
     this.Battery      = gsmBattery;
     this.Display      = gsmDisplay;
     this.displayIsSet = true;
     this.batteryIsSet = true;
     this.ownerIsSet   = true;
 }