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
- {
- private string model;
- private double? hoursIdle = 4d; // !
- private double? hoursTalk = 0.5d; // !
- public BatteryType BatteryType { get; set; }
- //property for model
- public string Model
- {
- get
- {
- return this.model;
- }
- private set // ????
- {
- this.model = value;
- }
- }
- //property for hours idle
- public double? HoursIdle
- {
- get { return this.hoursIdle; }
- private set // ????
- {
- if (value==null)
- {
- this.hoursIdle= hoursIdle;
- }
- }
- }
- //property for hours talk
- public double? HoursTalk
- {
- get { return this.hoursTalk; }
- private set // ????
- {
- if (value==null)
- {
- this.hoursTalk = hoursTalk;
- }
- }
- }
- //no default contructor
- //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;
- if (hoursIdle<0)
- {
- throw new ArgumentException();
- }
- this.HoursTalk = hoursTalk;
- if (hoursTalk<0)
- {
- throw new ArgumentException();
- }
- this.BatteryType = batteryType;
- }
- static void Main()
- {
- Battery battery = new Battery("varta");
- Console.WriteLine(battery.model);
- Console.WriteLine(battery.HoursIdle);
- Console.WriteLine(battery.hoursTalk);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement