public Laptop(string model, decimal price, string manufacturer = null, string processor = null, string ram = null, string graphicsCard = null, string hdd = null, string screen = null, Battery battery = null) : this(model, price) { this.Manufacturer = manufacturer; this.Processor = processor; this.RAM = ram; this.GraphicsCard = graphicsCard; this.HDD = hdd; this.Screen = screen; this.Battery = battery; }
static void Main() { Battery lion = new Battery("Li-Ion, 4-cells, 2550 mAh"); Battery nicd = new Battery("Ni-Cd", (float)4.5); Laptop lpt_second = new Laptop("Aspire E3-111-C5GL", (decimal)259.49); Laptop lpt_third = new Laptop("Acer some model", (decimal)1567.43, battery: nicd, processor: "3.2 GHz", ram: "16 GB"); Console.WriteLine(); Console.WriteLine(lpt_second.ToString()); Console.WriteLine(); Console.WriteLine(lpt_third.ToString()); }
static void Main() { Battery bat1 = new Battery("Li-Ion, 8-cells, 2550 mAh"); Battery bat2 = new Battery("Li-Ion", 4.5f); ICollection<Laptop> laptops = new List<Laptop>() { new Laptop("Lenovo Yoga 2 Pro", 869.88m, "Lenovo", "Intel Core i5-4210U (2-core, 1.70 - 2.70 GHz, 3MB cache)", "8 GB", "128GB SSD", "Intel HD Graphics 4400", "13.3\" (33.78 cm) – 3200 x 1800 (QHD+), IPS sensor display", bat1), new Laptop("Aspire E3-111-C5GL", 259.49m), new Laptop("Acer some model", 1567.4366m, battery : bat2, processor : "3.2 GHz", ram : "16 GB") }; foreach(var laptop in laptops) { Console.WriteLine(laptop); } }
public Laptop(string model, double price, string manufacturer = null, string processor = null, double?ram = null, string graphicsCard = null, int?hdd = null, double?screen = null, Battery battery = null) { 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 = battery; }