public static void Main()
Battery battery = new Battery("Batr", 20, 50, BatteryType.LiIon);
Display display = new Display(23, "Some colours");
GSM phone = new GSM("A70", "Samsung", 800, "Iva", new Battery("Bat", 3, 10, BatteryType.NiCd), new Display(6));
Console.WriteLine(phone.PrintInfo());
Console.WriteLine(battery.GetBatteryInfo());
Console.WriteLine(display.GetDisplayInfo());
private string model = null;
private string manufacturer = null;
private double price = 0;
private string owner = null;
private static GSM NokiaN95 = new GSM("N 95", "Nokia", 500, "Maria", new Battery("Batery", 20, 40, BatteryType.NiMH), new Display(5, "Blue"));
public GSM(string model, double price)
public GSM(string model, string manufacturer, double price, string owner)
this.Manufacturer = manufacturer;
public GSM(string model, string manufacturer, double price, string owner, Battery battery, Display display)
this.Manufacturer = manufacturer;
if(string.IsNullOrWhiteSpace(value))
throw new ArgumentException("Invalid Argument: The phone model can't be null or white space.");
public string Manufacturer
get {return manufacturer; }
if(string.IsNullOrWhiteSpace(value))
throw new ArgumentException("Invalid Argument: The manufacturer can't be null or white space.");
throw new ArgumentException("Invalid Argument: The price shouldn't be a negative number.");
if(string.IsNullOrWhiteSpace(value))
throw new ArgumentException("Invalid Argument: The owner can't be null or white space.");
throw new ArgumentException("Battery should not be null.");
throw new ArgumentException("Display is required.");
public static void PrintNokiaInfo()
Console.WriteLine("----- Info for Nokia -----");
Console.WriteLine("Model - {0} \nManufacturer - {1} \nPrice - {2} \nOwner - {3} \nBatery type - {4} \nDisplay - {5}",
GSM.NokiaN95.model, GSM.NokiaN95.manufacturer, GSM.NokiaN95.price, GSM.NokiaN95.owner, GSM.NokiaN95.battery.GetBatteryInfo(), GSM.NokiaN95.display.GetDisplayInfo());
public string PrintInfo()
string result = "-----Info for Phone-----\n";
result += "\nModel - " + this.Model;
result += "\nManufactirer - " + this.Manufacturer;
result += "\nPrice - " + this.Price;
result += "\nOwner - " + this.Owner;
result += "\nBattery type - " + this.battery.GetBatteryInfo();
result += "\nDisplay - " + this.display.GetDisplayInfo();
result += "\n\n-----------//-----------";
Undefined, LiIon, NiMH, NiCd
private string model = null;
private double idleTime = 0;
private double hoursTalk = 0;
private BatteryType batteryType;
public Battery(string model, double idleTime, double hoursTalk)
this.IdleTime = idleTime;
this.HoursTalk = hoursTalk;
public Battery(string model, double idleTime, double hoursTalk, BatteryType batteryType)
this.IdleTime = idleTime;
this.HoursTalk = hoursTalk;
this.BatteryType = batteryType;
if(string.IsNullOrWhiteSpace(value))
throw new ArgumentException("Invalid Argument: The battery model can't be null or white space.");
throw new ArgumentException("Invalid Argument: The idle time shouldn't be a negative number.");
get { return hoursTalk; }
throw new ArgumentException("Invalid Argument: The hours talks shouldn't be a negative number.");
public BatteryType BatteryType
if (value == BatteryType.Undefined)
throw new ArgumentException("Battery type should not be 'Undefined'.");
this.batteryType = value;
public string GetBatteryInfo()
string result = string.Format("Model: {0}, IdleTime: {1}, TalkingH: {2}, BatteryType: {3}",
this.Model, this.IdleTime, this.HoursTalk, this.BatteryType);
private string colours = null;
public Display(double size)
public Display(double size, string colours)
throw new ArgumentException("Invalid argument: the screen size shouldn't be anegative number.");
if(string.IsNullOrWhiteSpace(value))
throw new ArgumentException("Invalid Argument: The screen colours can't be null or white space.");
public string GetDisplayInfo()
string result = string.Format("Screen size: {0}, Screen colours: {1}", this.Size, this.Colours);