static void Main(string[] args) { Component storageHDD = new Component("HDD", "1024 GB", 118); Component storageSSD = new Component("SSD", "Samsung EVO 256 GB", 214.80); Component processorUnnamed = new Component("CPU", 169.99); Component processorIntel = new Component("CPU", "Intel Core-i7", 389.99); Component GPU = new Component("Video Card", "Nvidia GTX 970", 290.49); Computer firstPC = new Computer("PC-01", storageHDD, processorUnnamed); Computer epicPC = new Computer("Better-PC", storageSSD, processorIntel, GPU); List<Computer> listOfPCs = new List<Computer>(); listOfPCs.Add(epicPC); listOfPCs.Add(firstPC); foreach (Computer pc in listOfPCs) { Console.WriteLine(pc.GetComponentsAndTheirPrice()); } listOfPCs.Sort(delegate (Computer pc1, Computer pc2) { return pc1.Total.CompareTo(pc2.Total); }); foreach (Computer pc in listOfPCs) { Console.WriteLine(pc.GetComponentsAndTheirPrice()); } }
// Constructors. public Computer(string name, Component storage, Component processor, Component graphics) { this.Name = name; this.Storage = storage; this.CPU = processor; this.GPU = graphics; }
public Computer(string name, Component storage, Component processor) : this(name, storage, processor, null) { }