Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MobilePhoneDevice
- {
- class Battery
- {
- //const double DefaultHoursIdle = 4.0;
- //const double DefaultHoursTalk = 0.5;
- private string model;
- private double? hoursIdle = 4.0; // !
- private double? hoursTalk = 0.5;// !
- public BatteryType BatteryType { get; set; }
- //property for model
- public string Model
- {
- get
- {
- return this.model;
- }
- set // ????
- {
- this.model = value;
- }
- }
- //property for hours idle
- public double? HoursIdle
- {
- get { return this.hoursIdle; }
- set // ????
- {
- if (value==null)
- {
- //value = DefaultHoursIdle;
- value = hoursIdle;
- }
- this.hoursIdle = value;
- if (hoursIdle < 0)
- {
- throw new ArgumentException();
- }
- }
- }
- public double? HoursTalk
- {
- get { return this.hoursTalk; }
- set // ????
- {
- if (value == null)
- {
- //value = DefaultHoursTalk;
- value = hoursTalk;
- }
- this.hoursTalk = value;
- if (hoursTalk < 0)
- {
- throw new ArgumentException();
- }
- }
- }
- //public Battery()
- //{
- //}
- //constructor
- public Battery(string model)
- : this(model, null, null, BatteryType.Liion)
- {
- }
- //constructor
- //public Battery(string model, double hoursTalk):this(model,null,hoursTalk,BatteryType.Liion)
- //{
- //}
- //constructor
- public Battery(string model, double? hoursIdle, double? hoursTalk, BatteryType batteryType)
- {
- this.Model = model;
- this.HoursIdle = hoursIdle;
- this.HoursTalk = hoursTalk;
- this.BatteryType = batteryType;
- }
- static void Main()
- {
- Battery battery = new Battery("varta");
- Console.WriteLine(battery.model);
- Console.WriteLine(battery.HoursIdle);
- Console.WriteLine(battery.hoursTalk);
- Console.WriteLine("--");
- Console.WriteLine();
- Battery ba = new Battery("toshiba", 40, 49, BatteryType.NiCd);
- Console.WriteLine(ba.Model);
- Console.WriteLine(ba.HoursTalk);
- Console.WriteLine(ba.HoursIdle);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement