Пример #1
0
        private decimal Calculate(Computer computer)
        {
            var components = computer.Components;
            decimal price = components.Sum(component => component.Price);

            return price;
        }
Пример #2
0
 static void Main(string[] args)
 {
     Console.WriteLine("Enter computer name: ");
     string name = Console.ReadLine();
     Computer computer = new Computer(name, AddComponents());
     Console.WriteLine(computer.ToString());
 }
Пример #3
0
        static void Main()
        {
            Console.OutputEncoding = Encoding.UTF8;
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("bg-BG");

            Component mboardAsus = new Motherboard("ASUS p67le", 323.52m);
            Component mboardMSI = new Motherboard("MSI Z51 Pro", 289.90m, "not bad motherboard");

            Component gf560Ti = new GraphicsCard("Nvidia GeForce GTX 560 Ti", 400m, "Pretty good video card");
            Component radR9290 = new GraphicsCard("Sapphire ATI Radeon R9 290", 800m, "4 GB own memory!");

            Component intelI5 = new Processor("Intel i5 3920", 250m);
            Component amdOptX4 = new Processor("AMD Opteron X4", 180m, "2.2 GHz per core");

            Computer compAsusRadeonIntel = new Computer("Monster Machine", new List<Component>() { mboardAsus, radR9290, intelI5 });
            Computer compNvidiaMsiAmd = new Computer("A Good PC");

            compNvidiaMsiAmd.Components.Add(mboardMSI);
            compNvidiaMsiAmd.Components.Add(gf560Ti);
            compNvidiaMsiAmd.Components.Add(amdOptX4);

            List<Computer> computers = new List<Computer>() { compAsusRadeonIntel, compNvidiaMsiAmd };

            computers.OrderBy(c=>c.Price).ToList().ForEach(c => Console.WriteLine(c.ToString()));
            
        }
        static void Main()
        {
            var pc = new Computer("Dell");

            var computers = new List<Computer> {pc};

            var components = new List<Component>
            {
                new Component("Motherboard", "Asus", 200M),
                new Component("Processor", "Intel Core i7-4710HQ", 300M),
                new Component("RAM", "Kingston 2 X 4GB", 150M),
                new Component("Video card", "NVIDIA GeForce GTX 860M", 210M),
                new Component("HDD", "Toshiba 1TB", 120M)
            };

            foreach (var component in components)
            {
                pc.AddComponent(component);
            }

            // If there are more than one computer, of course:
            // computers.Sort();

            foreach (var computer in computers)
            {
                Console.WriteLine(computer.GetDescription());
            }

            // Test computer's ToString() method
            foreach (var computer in computers)
            {
                Console.WriteLine(computer);
            }
        }
        public static void Main()
        {
            Console.OutputEncoding = Encoding.Unicode;

            Computer pc1 = new Computer("Pravetz", "i7-3770k", 500m, "gotin processor", "NVIDIA 900-52055-0020-000 GRID K2 8GB", 150m, "qka", "ASRock 990FX Extreme3", 300.99m, "wow");

            Computer pc2 = new Computer("HP", "Core i3-3220 (3.30 GHz, 3 MB cache, 2 cores)", 300, "gotin processor", "Intel HD Graphics", 200m, "qka", "ASUS Z97-A LGA 1150 Intel Z97 HDMI SATA 6Gb/s ", 220m, "wow");

            Computer pc3 = new Computer("ASUS", "Core i5-4130 ", 420m, "gotin processor", "NVIDIA GeForce GTX 970", 1200m, "qka", "ASUS MAXIMUS VII HERO", 580m, "wow");

            var pc4 = new Computer("Lenovo");

            List<Computer> ListOfPCs = new List<Computer>();

            ListOfPCs.Add(pc1);
            ListOfPCs.Add(pc2);
            ListOfPCs.Add(pc3);
            ListOfPCs.Add(pc4);

            pc4.AddOrReplaceComponent(ComponentsEnum.GraphicsCard, "dger", 230, "rrtt");

            ListOfPCs = ListOfPCs.OrderBy(pc => pc.Price).ToList();

            foreach (var pc in ListOfPCs)
            {
                Console.WriteLine(pc);
            }
        }
Пример #6
0
        static void Main()
        {
            List<Computer> catalog = new List<Computer>();
            List<Component> components = new List<Component>();
            components.Add(new Component("HDD", 250.32m));
            components.Add(new Component("CPU", 560.45m));
            components.Add(new Component("RAM", 103.50m));
            Computer lenovo = new Computer("Lenovo", components);

            List<Component> components1 = new List<Component>();
            components1.Add(new Component("CPU", 231m));
            components1.Add(new Component("Motheboard", 351m));
            components1.Add(new Component("Graphics card", 351m));
            Computer dell = new Computer("Dell", components1);

            List<Component> components2 = new List<Component>();
            components2.Add(new Component("CPU", 134));
            components2.Add(new Component("RAM", 123.65m, "4GB"));
            Computer toshiba= new Computer("Toshiba", components2);

            catalog.Add(lenovo);
            catalog.Add(dell);
            catalog.Add(toshiba);

            var sortCatalog = catalog.OrderBy(computer => computer.Price);

            foreach (var computer in sortCatalog)
            {
                Console.WriteLine(computer);
            }
        }
Пример #7
0
        static void Main()
        {
            Computer veryExpensiveComputer = new Computer("Very Expensive Computer", new Component("Very Expensive Processor", 1500.00m), new Component(" Very Expensive Graphics Card", 1500.00m), new Component(" Very Expensive Motherboard", 1500.00m));
            Computer cheapComputer = new Computer("Cheap Computer", new Component("Cheap Processor", 20.00m), new Component("Cheap Graphics Card", 20.00m), new Component("Cheap Motherboard", 20.00m));
            Computer expensiveComputer = new Computer("Expensive Computer", new Component("Expensive Processor", 500.00m), new Component("Expensive Graphics Card", 500.00m), new Component("Expensive Motherboard", 500.00m));

            List<Computer> allComputers = new List<Computer>();
            allComputers.Add(cheapComputer);
            allComputers.Add(expensiveComputer);
            allComputers.Add(veryExpensiveComputer);

            foreach (Computer computer in allComputers.OrderBy(computer => computer.CalculateComputerPrice()))
            {
                computer.PrintComputerInformation();
                Console.WriteLine();
            }
        }
Пример #8
0
        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");

            Computer myComputer = new Computer("Shtaiga 23XR");

            myComputer.AddComponent(new Component("Intel i5", 127.00m, "2.4 GHz 4 MB cache"));
            myComputer.AddComponent(new Component("Maxtor", 222.10m, "500 GB"));
            myComputer.AddComponent(new Component("ATI Radeon 9990", 327.00m, "2GB, crossfire, shader 5.0"));
            myComputer.AddComponent(new Component("Seagate", 97.20m, "4 GB DDR2"));
            myComputer.AddComponent(new Component("Gigabyte 2", 427.00m));

            Computer hisComputer = new Computer("Axort 111");

            hisComputer.AddComponent(new Component("AMD Athlon", 123.00m, "1.4 GHz 1 MB cache"));
            hisComputer.AddComponent(new Component("Maxtor", 122.10m, "50 GB"));
            hisComputer.AddComponent(new Component("Nvidia GForce 4", 127.00m, "1GB"));
            hisComputer.AddComponent(new Component("Atkinson", 17.20m, "512 MB, DDR2"));
            hisComputer.AddComponent(new Component("Gigabyte 1", 127.00m));

            Computer thierComputer = new Computer("Qekd 001");

            thierComputer.AddComponent(new Component("AMD Senetron 2", 223.00m, "3.4 GHz 1 MB cache"));
            thierComputer.AddComponent(new Component("Maxtor III", 322.10m, "150 TB"));
            thierComputer.AddComponent(new Component("Nvidia GForce 8", 327.00m, "8GB"));
            thierComputer.AddComponent(new Component("Oenna", 127.20m, "8 GB, DDR4"));
            thierComputer.AddComponent(new Component("ASUS 8", 727.00m));

            List<Computer> computers = new List<Computer>()
            {
                myComputer,
                hisComputer,
                thierComputer
            };

            computers.Sort((a, b) => a.Price < b.Price ? -1 : a.Price > b.Price ? 1 : 0);

            foreach (var comp in computers)
            {
                Console.WriteLine(comp);
            }
        }
Пример #9
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.Unicode;
            
            string[] lines = System.IO.File.ReadAllLines(@"D:\OOP\DefiningClasses\PCCatalog\input.txt");

            Components component = new Components(lines[2], lines[3],(lines[4]));
            Components componentOne = new Components(lines[5], lines[6],(lines[7]));
            Components componentTwo = new Components(lines[8],lines[9]);
            Components componentThr = new Components(lines[10],lines[11]);
            List<Components> CompParts = new List<Components>();
            CompParts.Add(component);
            CompParts.Add(componentOne);
            CompParts.Add(componentTwo);
            CompParts.Add(componentThr);
            Computer comp = new Computer(lines[0], double.Parse(lines[1]), CompParts);
            List<List<String>>data=Computer.ComponentsData(comp.comps);
            List<String> parts = data[0];
            List<String> price = data[1];
            Computer.Display(comp.Name,comp.CompPrice,parts, price);
        }
Пример #10
0
        public static List<Computer> AddComputers()
        {
            List<Computer> computers = new List<Computer>();
            string ch = null;

            do
            {
                Console.WriteLine("Enter a computer name: ");
                string name = Console.ReadLine();

                List<Components> components = AddComponents();

                Computer computer = new Computer(name, components);
                computers.Add(computer);

                Console.WriteLine("\n Do you want to add a new computer? (y/n) ");
                ch = Console.ReadLine();
            }
            while (ch != "n" && ch != "y");
            return computers;
        }
Пример #11
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("bg-BG");

            int computersCount = 5;
            Computer[] computers = new Computer[computersCount];
            var random = new Random();
            for (int i = 0; i < computersCount; i++)
            {
                computers[i] = new Computer("someName",
                    new Component("AMD FX8320 Processor", Convert.ToDecimal(random.NextDouble() * 1000)),
                    new Component("Asrock 990FX Extreme 3", Convert.ToDecimal(random.NextDouble() * 1000)),
                    new Component("HDD WD BLUE 1 TB", Convert.ToDecimal(random.NextDouble() * 1000)));
            }

            int index = 1;
            foreach (var computer in computers.OrderBy(x => x.Price))
            {
                Console.WriteLine("Computer #{0}", index++);
                Console.WriteLine(computer);
                Console.WriteLine();
            }
        }
Пример #12
0
        static void Main(string[] args)
        {
            Computer one = new Computer("HP", 399.99m);
            Computer two = new Computer("Dell", 499.99m);
            Computer three = new Computer("Apple", 4959.99m);
            Computer four = new Computer("Acer", 899.99m);

            four.MotherboardSet = new Component("GamineOne", 49.99m);
            four.GPUSet = new Component("NVidia", 51m, "970 GTX");
            var collection = new List<Computer>();
            collection.Add(one);
            collection.Add(two);
            collection.Add(three);
            collection.Add(four);

            var sorted = collection.OrderByDescending(x => x.PriceSet);
            foreach (var item in sorted)
            {
                item.Display();
            }

            Console.WriteLine(one);
        }
Пример #13
0
        static void Main()
        {
            Console.OutputEncoding = Encoding.UTF8;
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("bg-BG");

            Component mcardVLC = new Motherboard("VLC", (decimal)185.98);
            Component vcardRadeon = new GraphicCard("Radeon", (decimal)102.34, "the best grafic card forever");
            Component vcardGeForce = new GraphicCard("GeForce", (decimal)154.45, "is not worth");

            Component procIntel = new Processor("Intel", (decimal)346.563, "can be better");
            Component procAMD = new Processor("AMD", (decimal)405.239, "always the best");

            Computer compAMDRadeon = new Computer("Fasty", new List<Component>() { mcardVLC, vcardRadeon, procAMD });
            Computer compIntelGeForce = new Computer("Star");
            //Console.WriteLine(compIntelGeForce);
            compIntelGeForce.Components.Add(vcardGeForce);
            compIntelGeForce.Components.Add(mcardVLC);

            List<Computer> computers = new List<Computer>() { compAMDRadeon, compIntelGeForce };

            computers.OrderBy(c => c.Price).ToList().ForEach(c => Console.WriteLine(c.ToString()));
            //computers.OrderBy(p => p.TotalPrice).ToList().ForEach(p => Console.WriteLine(p.ToString()));

        }
Пример #14
0
        static void Main(string[] args)
        {
            List<Computer> computers = new List<Computer>();

            Computer computer1 = new Computer("Terminator", new List<Component>()
            {
                new Component( "Motherboard", 80.00m),
                new Component("Processor",250.90m,"Intel Core I5"),
                new Component("RAM Memory",80.90m,"8GB DDR4"),
                new Component("Hard Drive", 150.00m),
                new Component("Graphics Card",550.25m,"nVidia")
            });
            computers.Add(computer1);
            Computer computer2 = new Computer("Turtle", new List<Component>()
            {
                new Component( "Motherboard", 50.00m),
                new Component("Processor",180.60m,"Intel Dual Core"),
                new Component("RAM Memory",40.40m,"4GB DDR3"),
                new Component("Hard Drive", 150.00m,"500GB"),
                new Component("Graphics Card",150.25m,"nVidia")
            });
            computers.Add(computer2);
            Computer computer3 = new Computer("Falcon", new List<Component>()
            {
                new Component( "Motherboard", 350.00m),
                new Component("Processor",700.99m,"Intel Core I7"),
                new Component("RAM Memory",500.40m,"16GB DDR5"),
                new Component("Hard Drive", 750.00m,"500GB SSD + 1TB"),
                new Component("Graphics Card",1150.25m,"nVidia")
            });
            computers.Add(computer3);
            foreach (var computer in computers.OrderByDescending(x => x.TotalPrice))
            {
                computer.PrintConfig();
            }
        }
Пример #15
0
 static void Main()
 {
     Computer lenovo = new Computer("Lenovo", "a", "b", "c", "d", "e", "f", 2.39m, 3.15m, 6.20m, 9.20m);
     Computer asus = new Computer("Asus", "g", "h", "i", 3.65m, 2.56m, 5.33m, 9.18m);
     Computer toshiba = new Computer("Toshiba", "j", "k", "l", 2.38m, 5.16m, 3.22m, 10.55m);
     List<Computer> computers = new List<Computer>();
     computers.Add(lenovo);
     computers.Add(asus);
     computers.Add(toshiba);
     List<Computer> sortedComputers = computers.OrderBy(computer => computer.Price).ToList();
     foreach (Computer computer in sortedComputers)
         Console.WriteLine(computer);
 }