예제 #1
0
 public Computer(string name, Component hdd, Component processor, decimal price)
 {
     this.Name = name;
     this.Hdd = hdd;
     this.Processor = processor;
     this.Price = price;
 }
예제 #2
0
 public void AddComponents(Component[] Components)
 {
     this.components = new List<Component>();
     foreach (var component in Components)
     {
         this.components.Add(component);
     }
 }
예제 #3
0
        static void Main()
        {
            var pc = new Computer();
            pc.Name = "My PC";

            var ram = new Component("RAM", 150.5m);
            var cpu = new Component("Processor", 259.99m);

            pc.Components = new List<Component>();
            pc.Components.Add(ram);
            pc.Components.Add(cpu);
            pc.Components.Add(new Component("Graphics", 95.66m));

            ram.Details = "8 GB DDR3, KINGSTON";
            cpu.Details = "Intel Core® i5";

            var pc1 = new Computer("Gosho's PC");
            var pc2 = new Computer("Pesho's PC");
            var pc3 = new Computer("Vlado's PC");

            pc1.Components = new List<Component>();
            pc2.Components = new List<Component>();
            pc3.Components = new List<Component>();

            pc1.Components.Add(new Component("RAM", 167.65m, "6 GB DDR3, KINGSTON"));
            pc1.Components.Add(new Component("Graphics", 252m, "512 MB"));
            pc1.Components.Add(new Component("CPU", 199.99m, "AMD Athlon 64 x2, 2.11 GHz"));
            pc1.Components.Add(new Component("HDD", 68m, "Hitachi"));

            pc2.Components.Add(new Component("RAM", 100m, "4 GB DDR3, KINGSTON"));
            pc2.Components.Add(new Component("Graphics", 212.35m, "1GB"));
            pc2.Components.Add(new Component("HDD", 188m, "500 RPM"));

            pc3.Components.Add(new Component("RAM", 129.65m, "4 GB DDR3"));
            pc3.Components.Add(new Component("HDD", 212.35m, "1GB"));
            pc3.Components.Add(new Component("Processor", 250m, "Intel Core 2 Duo, 2.8 GHz"));

            var computers = new List<Computer>();
            computers.Add(pc);
            computers.Add(pc1);
            computers.Add(pc2);
            computers.Add(pc3);

            var sortedComputers = computers
                .OrderBy(x => x.TotalComponentsPrice(x.Components));

            foreach (var computer in sortedComputers)
            {
                computer.PrintInfo();
                Console.WriteLine();
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            Component VGA = new Component("VGA", "Inteli HD Graphics 4400", 256.6M);
            Component ssd = new Component("SSD 256GB", "Samsung 850 EVO", 200.0M);
            Component cpu = new Component("CPU", "i5-3770", 120.0M);

            List<Computer> computers = new List<Computer>()
            {
                new Computer("Dell",VGA,ssd),
                new Computer("Intel",VGA,ssd,cpu),

            };
            computers.OrderBy(computer => computer.Price).ToList().ForEach(Console.WriteLine);
        }
예제 #5
0
 public void AddComponent(Component component)
 {
     var list = this.Components;
     list.Add(component);
     this.Components = list;
 }