예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Build your PC today");

            // User gets into the shop
            User user = new User();

            // User wants to buy a computer
            CPU         cpu         = new CPU();
            RAM         ram         = new RAM();
            PowerSupply powerSupply = new PowerSupply();

            PC newlyCreatedPC = new PC();

            newlyCreatedPC.AddComponent(cpu);
            newlyCreatedPC.AddComponent(ram);


            if (!(newlyCreatedPC.HasRequiredComponents() &&
                  newlyCreatedPC.HasPositivePowerBalance() &&
                  newlyCreatedPC.HasNegativeTemperatureBalance()))
            {
                Console.WriteLine("PC not working, we are not selling it!");
                //throw new PCNotWorkingException();
            }

            newlyCreatedPC.AddComponent(powerSupply);

            // User pays for the computer
            user.AddPC(newlyCreatedPC);
            Console.WriteLine("Congrats! You bought your first computer!");
        }
예제 #2
0
        static void Main(string[] args)
        {
            RAM         ram   = new RAM("GoodRAM", -50, -10);
            CPU         cpu   = new CPU("Intel Core i3", -20, -30);
            PowerSupply power = new PowerSupply("Silentium PC", 100, -20);
            Fan         fan   = new Fan("Corsair", -10, 100);
            Fan         fan2  = new Fan("Corsair", -10, 100);

            Computer comp = new Computer(4);

            comp.MountComponent(ram);
            comp.MountComponent(cpu);
            comp.MountComponent(power);
            comp.CheckIfWorks();
            comp.MountComponent(fan);
            comp.CheckIfWorks();
            comp.MountComponent(fan2);
        }