コード例 #1
0
        static void Main()
        {
            List<Component> parts = new List<Component>()
            {
                new Component("CPU", 123.4M, "good"),
                new Component("RAM", 23.4M, "bad"),
                new Component("Screen", 13.4M),
                new Component("CD", 12.4M, "nice"),
                new Component("Motherboard", 1213.4M)
            };

            Computer myComputer = new Computer("My Pc", parts);
            Computer newComputer = new Computer("Other PC");
            Computer newComp = new Computer("New PC", new List<Component>()
            {
                new Component("CPU", 0.4M, "good"),
                new Component("RAM", 0.004M, "bad"),
            });
            myComputer.GetName();
            myComputer.GetComponents();
            myComputer.GetPrice();
            Console.WriteLine();

            newComputer.GetName();
            newComputer.GetComponents();
            newComputer.GetPrice();
            Console.WriteLine();

            List<Computer> computers = new List<Computer>() { myComputer, newComputer, newComp };
            computers.Sort((x, y) => (int)(x.Price - y.Price));
            computers.ForEach(Console.WriteLine);
        }
コード例 #2
0
ファイル: Catalogue.cs プロジェクト: BAleksiev/OOP-Course
        static void Main(string[] args)
        {
            List<Component> comp1components = new List<Component>();
            comp1components.Add(new Component("Processor", (decimal)432.45, "INTEL I5 3.5 GHz"));
            comp1components.Add(new Component("RAM", (decimal)111.21, "Corsair Vengence 8 GB"));
            comp1components.Add(new Component("Motherboard", (decimal)156.78, "Assus"));
            comp1components.Add(new Component("Graphics Card", (decimal)678.00, "Radeon Sapphire HD7895"));
            comp1components.Add(new Component("HDD", (decimal)110.12, "Western Digital 500GB"));
            comp1components.Add(new Component("Power Supply", (decimal)250.48, "Cooler Master 650W Gold"));
            comp1components.Add(new Component("Case", (decimal)290.00, "CM Strom Trooper"));
            Computer comp1 = new Computer("Gaming Build", comp1components);

            List<Component> comp2components = new List<Component>();
            comp2components.Add(new Component("Processor", (decimal)785.35, "INTEL I7 3.1 GHz"));
            comp2components.Add(new Component("RAM", (decimal)230.57, "Corsair Vengence 16 GB"));
            comp2components.Add(new Component("Motherboard", (decimal)156.78, "Assus"));
            comp2components.Add(new Component("Graphics Card", (decimal)678.01, "Radeon Sapphire HD7895"));
            comp2components.Add(new Component("HDD", (decimal)350.12, "Sony 1TB SSD"));
            comp2components.Add(new Component("Power Supply", (decimal)635.78, "Cooler Master 1500W Gold"));
            comp2components.Add(new Component("Case", (decimal)290.00, "CM Strom Trooper"));
            Computer comp2 = new Computer("Ulta PC", comp2components);

            List<Component> comp3components = new List<Component>();
            comp3components.Add(new Component("Processor", (decimal)56.5, "INTEL Pentium 3"));
            comp3components.Add(new Component("RAM", (decimal)8.49, "Kingston 512MB"));
            comp3components.Add(new Component("Motherboard", (decimal)12.8, "Assus"));
            comp3components.Add(new Component("Graphics Card", (decimal)150.78, "ATI Radeon HD3580"));
            comp3components.Add(new Component("HDD", (decimal)48.99, "Sony 200GB"));
            comp3components.Add(new Component("Power Supply", (decimal)55.55, "200W"));
            comp3components.Add(new Component("Case", (decimal)17.2, "Classic White Case"));
            Computer comp3 = new Computer("PC fourth hand", comp3components);

            List<Computer> computersList = new List<Computer>();
            computersList.Add(comp1);
            computersList.Add(comp2);
            computersList.Add(comp3);

            computersList.Sort();

            foreach (Computer computer in computersList)
            {
                Console.WriteLine(computer.Display());
            }
        }
コード例 #3
0
ファイル: PCCatalogue.cs プロジェクト: ttitto/CSharp
        public static void Main(string[] args)
        {
            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");
            compIntelGeForce.Components.Add(vcardGeForce);
            compIntelGeForce.Components.Add(mcardVLC);

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

            computers.OrderBy(c => c.Price).ToList().ForEach(c => Console.WriteLine(c.ToString()));
        }