Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _2.LaptopShop
- {
- public class Laptop
- {
- private string model;
- private string manifacturer;
- private string processor;
- private int ram;
- private string graphicsCard;
- private string hdd;
- private string screen;
- private Baterry laptobBaterry;
- private double price;
- public Laptop(string model, double price)
- {
- this.Model = model;
- this.Price = price;
- }
- public Laptop(string model, double price, string manifacturer = null, string processor = null, int ram = 0, string graphicsCard = null,
- string hdd = null, string screen = null, string batt = null, decimal battLife = 0):this(model,price)
- {
- this.Manifacturer = manifacturer;
- this.Processor = processor;
- this.Ram = ram;
- this.GraphicsCard = graphicsCard;
- this.Hdd = hdd;
- this.Screen = screen;
- this.laptobBaterry = new Baterry(batt, battLife);
- }
- public string Model
- {
- get
- {
- return this.model;
- }
- set
- {
- if (string.IsNullOrEmpty(value))
- {
- throw new ArgumentException("The model cannot be a empty");
- }
- this.model = value;
- }
- }
- public string Manifacturer
- {
- get
- {
- return this.manifacturer;
- }
- set
- {
- if (string.IsNullOrEmpty(value))
- {
- throw new ArgumentException("Manifacturer value cannot be a empty");
- }
- this.manifacturer = value;
- }
- }
- public string Processor
- {
- get
- {
- return this.processor;
- }
- set
- {
- if (string.IsNullOrEmpty(value))
- {
- throw new ArgumentException("Processor value cannot be a empty");
- }
- this.processor = value;
- }
- }
- public int Ram
- {
- get
- {
- return this.ram;
- }
- set
- {
- if (value < 0)
- {
- throw new ArgumentException("RAM cannot be a negative");
- }
- this.ram = value;
- }
- }
- public string GraphicsCard
- {
- get
- {
- return this.graphicsCard;
- }
- set
- {
- if (string.IsNullOrEmpty(value))
- {
- throw new ArgumentException("The graphicsCard cannot be a empty");
- }
- this.graphicsCard = value;
- }
- }
- public string Hdd
- {
- get
- {
- return this.hdd;
- }
- set
- {
- if (string.IsNullOrEmpty(value))
- {
- throw new ArgumentException("hdd cannot be a empty");
- }
- this.hdd = value;
- }
- }
- public string Screen
- {
- get
- {
- return this.screen;
- }
- set
- {
- if (string.IsNullOrEmpty(value))
- {
- throw new ArgumentException("The screen cannot be a empty");
- }
- this.screen = value;
- }
- }
- public double Price
- {
- get
- {
- return this.price;
- }
- set
- {
- if (value < 0)
- {
- throw new ArgumentException("The price cannot be a negative");
- }
- this.price = value;
- }
- }
- public override string ToString()
- {
- string output = string.Format("Model: {0}\n", this.model);
- output += string.Format("Manifacturer: {0}\n", this.manifacturer);
- output += string.Format("Processor: {0}\n", this.processor);
- output += string.Format("RAM: {0} GB\n", this.ram);
- output += string.Format("GraphicssCard: {0}\n", this.graphicsCard);
- output += string.Format("HDD: {0}\n", this.hdd);
- output += string.Format("Screen: {0}\n", this.screen);
- output += string.Format("{0}", this.laptobBaterry);
- output += string.Format("Price: {0:f2}lv", this.price);
- return output;
- }
- static void Main()
- {
- Laptop lenovo = new Laptop("Lenovo Yoga 2 Pro", 2259.00, "Lenovo", "Intel Core i5-4210U (2-core, 1.70 - 2.70 GHz, 3MB cache)",
- 8, "Intel HD Graphics 4400", "128GB SSD", "13.3\" (33.78 cm) – 3200 x 1800 (QHD+), IPS sensor display",
- "Li-Ion, 4-cells, 2550 mAh", 4.5m);
- Console.WriteLine(lenovo.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement