Created
November 19, 2015 19:31
-
-
Save Jore2/344efb0811a4019113fc to your computer and use it in GitHub Desktop.
02.LapTopShop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace _02.LaptopShop | |
{ | |
public class Battery | |
{ | |
private double batteryLife; | |
private string model; | |
public double BatteryLife | |
{ | |
get | |
{ | |
return this.batteryLife; | |
} | |
set | |
{ | |
if (value<0) | |
{ | |
throw new ArgumentException(); | |
} | |
else | |
{ | |
this.batteryLife = value; | |
} | |
} | |
} | |
public string Model | |
{ | |
get | |
{ | |
return this.model; | |
} | |
set | |
{ | |
if (string.IsNullOrEmpty(value)) | |
{ | |
throw new ArgumentNullException(); | |
} | |
else | |
{ | |
this.model = value; | |
} | |
} | |
} | |
public Battery(double batteryLife,string model) | |
{ | |
this.BatteryLife = batteryLife; | |
this.Model = model; | |
} | |
public Battery():this(0,"Li-Lon") | |
{ | |
} | |
public Battery(Battery b):this(b.BatteryLife, b.Model) | |
{ | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace _02.LaptopShop | |
{ | |
public class LapTop | |
{ | |
private string model; | |
private string manufacturer; | |
private string processor; | |
private int ram; | |
private string graphicsCard; | |
private int hdd; | |
private double screen; | |
private decimal price; | |
private Battery battery; | |
public string Model | |
{ | |
get | |
{ | |
return this.model; | |
} | |
set | |
{ | |
if (string.IsNullOrEmpty(value)) | |
{ | |
throw new ArgumentNullException(); | |
} | |
else | |
{ | |
this.model = value; | |
} | |
} | |
} | |
public string Manufacturer | |
{ | |
get | |
{ | |
return this.manufacturer; | |
} | |
set | |
{ | |
if (string.IsNullOrEmpty(value)) | |
{ | |
throw new ArgumentException(); | |
} | |
else | |
{ | |
this.manufacturer = value; | |
} | |
} | |
} | |
public string Processor | |
{ | |
get | |
{ | |
return this.processor; | |
} | |
set | |
{ | |
if (string.IsNullOrEmpty(value)) | |
{ | |
throw new ArgumentException(); | |
} | |
else | |
{ | |
this.processor = value; | |
} | |
} | |
} | |
public int Ram | |
{ | |
get | |
{ | |
return this.ram; | |
} | |
set | |
{ | |
if (value < 0) | |
{ | |
throw new ArgumentException(); | |
} | |
this.ram = value; | |
} | |
} | |
public string GraphicsCard | |
{ | |
get | |
{ | |
return this.graphicsCard; | |
} | |
set | |
{ | |
if (string.IsNullOrEmpty(value)) | |
{ | |
throw new ArgumentException(); | |
} | |
else | |
{ | |
this.graphicsCard = value; | |
} | |
} | |
} | |
public int Hdd | |
{ | |
get | |
{ | |
return this.hdd; | |
} | |
set | |
{ | |
if (value < 0) | |
{ | |
throw new ArgumentException(); | |
} | |
this.hdd = value; | |
} | |
} | |
public double Screen | |
{ | |
get | |
{ | |
return this.screen; | |
} | |
set | |
{ | |
if (value<0) | |
{ | |
throw new ArgumentException(); | |
} | |
else | |
{ | |
this.screen = value; | |
} | |
} | |
} | |
public Battery Battery | |
{ | |
get | |
{ | |
return this.battery; | |
} | |
set | |
{ | |
battery = new Battery(value); | |
} | |
} | |
public decimal Price | |
{ | |
get | |
{ | |
return this.price; | |
} | |
set | |
{ | |
if (value < 0) | |
{ | |
throw new ArgumentException("Price cant be negative value."); | |
} | |
else | |
{ | |
this.price = value; | |
} | |
} | |
} | |
public LapTop(LapTop lap):this(lap.Model,lap.Manufacturer,lap.Processor,lap.Ram,lap.GraphicsCard,lap.Hdd,lap.Screen,lap.Price,lap.Battery.BatteryLife,lap.Battery.Model) | |
{ | |
} | |
public LapTop(string model, string manufacturer, string processor, int ram, string graphicsCard, int hdd, double screen, decimal price, double batteryLife, string batteryModel) | |
{ | |
this.Model = model; | |
this.Manufacturer = manufacturer; | |
this.Processor = processor; | |
this.Ram = ram; | |
this.GraphicsCard = graphicsCard; | |
this.Hdd = hdd; | |
this.Screen = screen; | |
this.Price = price; | |
this.Battery = new Battery(batteryLife,batteryModel); | |
} | |
public LapTop(string model, decimal price) : this(model, "Lenovo Yoga 2 Pro", | |
"Intel Core i5-4210U (2-core, 1.70 - 2.70 GHz, 3MB cache)", 0, | |
"Intel HD Graphics 4400", 0, 0, price,0, "Li-Ion, 4-cells, 2550 mAh") | |
{ | |
} | |
public override string ToString() | |
{ | |
StringBuilder str = new StringBuilder(); | |
str.AppendFormat("model {0}\nmanufacturer {1}\nprocessor {2}\nRaM {3} GB\ngraphics card {4}\nHDD {5}\nscreen {6}\"\nbattery {7}\nbattery life {8} hours\nprice {9} lv." | |
, Model, Manufacturer, Processor, Ram, GraphicsCard, Hdd, Screen, Battery.Model, Battery.BatteryLife, Price); | |
return str.ToString(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment