示例#1
0
文件: PCCatalog.cs 项目: Penkov/OOP
        static void Main()
        {
            Components Motherboard = new Components();
            Motherboard.Name = "IntelALTServer";

            Motherboard.Price = 10.32m;
            Motherboard.Details = "No details";

            Components Processor = new Components("Pentium Dual-Core",14.32m, "All details");

            Components Ram = new Components("DDR2-400",10.43m,"All details");

            Components GraphicsCard = new Components("DB-15 VGA",10.32m, "No details");

            Components Hdd = new Components("256 SSD", 16.00m,"100 Terrabytes");

            List<Computer> computers = new List<Computer>
            {
                new Computer("ACCER", Motherboard, Processor, Ram, GraphicsCard, Hdd, 3200.43m),
                new Computer("APPLE", Motherboard, Processor, Ram, GraphicsCard, Hdd, 4433.65m),
                new Computer("LENOVO", Motherboard, Processor, Ram, GraphicsCard, Hdd,5800.65m),
                new Computer("ASUS", Motherboard, Processor, Ram, GraphicsCard, Hdd,11000.96m)
            };
            computers.Sort((x, y) => x.Price.CompareTo(y.Price));
            foreach (Computer pc in computers)
            {
                Console.WriteLine(pc);
            }
        }
示例#2
0
文件: Computer.cs 项目: Penkov/OOP
 public Computer(string name, Components motherboard, Components processor,
        Components ram, Components graphicsCard, Components hdd, decimal price)
 {
     this.Name = name;
     this.Motherboard = motherboard;
     this.Processor = processor;
     this.RAM = ram;
     this.GraphicsCard = graphicsCard;
     this.Hdd = hdd;
     this.Price = price;
 }
示例#3
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);
        }
示例#4
0
        static List<Components> AddComponents()
        {
            List<Components> components = new List<Components>();
            string ch = null;

            do
            {
                Console.WriteLine("Enter component name: ");
                string name = Console.ReadLine();
                Console.WriteLine("Enter the component description: ");
                string desc = Console.ReadLine();
                Console.WriteLine("Enter the component price: ");
                double price = double.Parse(Console.ReadLine());

                Components component = new Components(name, desc, price);
                components.Add(component);

                Console.WriteLine("\n Do you want to add another component (y\n)? ");
                ch = Console.ReadLine();

            } while (ch != "y" && ch != "n");
            return components;
        }