public void TestMethod1()
        {
            var computer    = new Computer();       // composite
            var motherboard = new Motherboard(125); // composite
            var cpu         = new Cpu(250);         // leaf
            var ram         = new Ram(160);         // leaf
            var drive       = new Ssd(250);         // leaf

            motherboard.Add(cpu);
            motherboard.Add(ram);

            computer.Add(motherboard);
            computer.Add(drive);

            Assert.AreEqual(computer.Price, 785);
        }
Пример #2
0
        public void TestMethod1()
        {
            var computer = new Computer(); // composite
                var motherboard = new Motherboard(125); // composite
                    var cpu = new Cpu(250); // leaf
                    var ram = new Ram(160); // leaf
                var drive = new Ssd(250); // leaf

            motherboard.Add(cpu);
            motherboard.Add(ram);

            computer.Add(motherboard);
            computer.Add(drive);

            Assert.AreEqual(computer.Price, 785);
        }
Пример #3
0
        private void Add(Component component, int quantity = 1)
        {
            if (InvalidComponent(component, quantity))
            {
                ThrowInvalidAdd();
            }

            Computer.Add(component, quantity);
        }
Пример #4
0
        public void add_register_b(byte eregister, byte aregister, byte result, byte flagresult)
        {
            //c=0x01, p=0x04, ac=0x10, z=0x40, sign=0x80
            //
            // E = F3H
            // A = 45H   38H
            // FLAGS = cy=1, ac=0, p=0, z=0, s=0

            // E = 85H
            // A = 1EH  A3H
            // FLAGS = cy=0, ac=1, p=1, z=0, s=1
            // 94h

            var computer = new Computer();

            computer.Reset();
            computer.ComputerMemory[computer.PC] = 0xf8 + 0x03;
            computer.E = eregister;
            computer.A = aregister;
            computer.Add();

            Assert.Equal(result, computer.A);
            Assert.Equal(flagresult, computer.Flags.Register);
        }
 public void BuildCASE()
 {
     computer.Add("正常機殼");
 }
Пример #6
0
 /// <summary>
 /// 构建操作1
 /// </summary>
 public override void BuildCPU() => computer.Add("CPU By SecondBuilder");
 public override void BuildPartCpu()
 {
     computer.Add("cpu");
 }
Пример #8
0
        static void Main(string[] args)
        {
            Software[] softs = new Software[]
            {
                new Software("Quicker"),
                new Software("Volodya"),
                new Software("Pinguin"),
                new Software("Sweety Betty"),
                new Software("Mother Russia"),
                new Software("Joseph from USSR"),
                new Software("Slim Shady"),
                new Software("Daddy"),
                new Software("Destroyer"),
            };

            Word[] redactors = new Word[]
            {
                new Word(8, 2, 4, 2),
                new Word(5, 3, 3, 3),
                new Word(2, 4, 2),
                new Word(5, 5, 1, 7),
                new Word(4, 1, 3, 3),
                new Word(1, 2, 7, 5),
                new Word(7, 3, 3, 3),
                new Word(5, 4, 5),
            };

            Game[] games = new Game[]
            {
                new Game("Action", "1"),
                new Game("Shooter", "2"),
                new Game("Platformer", "3"),
                new Game("Action", "4"),
                new Game("Beat-em up", "5"),
                new Game("Stealth", "6"),
                new Game("Survival", "7"),
                new Game("Action", "8"),
                new Game("Logic", "9"),
                new Game("Action", "10"),
                new Game("Simulator", "11"),
            };

            Game.Update update = new Game.Update("V2.0");


            Controller.FindGameForType(games);
            Controller.FindRedactorForVersion(redactors);
            Controller.ShowSoftAlphabetically(softs);

            Console.WriteLine($"There are {(int)Calendar.Days} days in year, {(int)Calendar.Month} monthes and {(int)Calendar.DayOfWeek} days in week");

            Console.WriteLine();

            update.CheckForUpdate();
            update.ShowCurrentVersion();


            Computer pc = new Computer("Dell", "Inspiron", "Windows");

            pc.Add(softs[2]);
            pc.Add(softs[4]);
            pc.Add(softs[5]);
            pc.Add(softs[0]);

            pc.ShowList();

            pc.Remove(softs[4]);

            Console.WriteLine("\nSoft after removing\n");

            pc.ShowList();

            pc.ToString();
        }
Пример #9
0
 public override void BuildPartCPU()
 {
     computer.Add("CPU2");
 }
Пример #10
0
        static void Main(string[] args)
        {
            {
                //            Computer PC1 = new Computer("Hp 310", 751.5, 4, 220, 3, "Intel core i5", "NVidea 980", 16384, 1);
                //            Printed_devices Printer1 = new Printed_devices("Canon i1900", 199.9, 20, 220, 5, true, true, 12);
                //            Skanner Skanner1 = new Skanner("Canon Lide 120", 59.9, 33, 220, 1, 600, "A3", 25);
                //            Technics IX = new Computer("‎Apple MacBook Air 13", 1312, 3, 220, 3, "Intel Core i5 5350U", " Intel HD Graphics 6000", 8192, 9);
                //            */
                //            /* 5 laba
                //             * Console.WriteLine("Show price in IProduct \n \n");
                //               ((IProduct)PC1).ShowPrice();
                //               Console.WriteLine("\n\n Show price in IComputer \n\n");
                //               ((IComputer)PC1).ShowPrice();

                //               Console.WriteLine("\n\n\nis\\as");
                //               IProduct NewProduct = IX;
                //               Console.WriteLine(NewProduct is Computer);
                //               Console.WriteLine(NewProduct is Product);
                //               Console.WriteLine(NewProduct is Program);

                //               Console.WriteLine("As 1:");
                //               Product a = NewProduct as Product;
                //               Console.WriteLine(a);
                //               Console.WriteLine("As 2:");
                //               Skanner b = NewProduct as Skanner;
                //               Console.WriteLine(b);

                //               Technics[] stock = new Technics[4];
                //               stock[0] = PC1;
                //               stock[1] = Printer1;
                //               stock[2] = Skanner1;
                //               stock[3] = IX;

                //               Console.WriteLine("I see in stock:");
                //               foreach (var item in stock)
                //               {
                //                   Console.WriteLine("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
                //                   Console.WriteLine(item.ToString());
                //               } */

                ///*6 laba
                // Console.WriteLine("LABORATORY:");
                //  lab<Technics> laboratory = new lab<Technics>();

                //  laboratory.Add(PC1);
                //  laboratory.Add(Printer1);
                //  laboratory.Add(Skanner1);
                //  laboratory.Add(IX);



                //  Controller controller = new Controller(laboratory);

                //  Console.WriteLine("\n\nGETLIST\n");
                //  controller.GetList();


                //  Console.WriteLine("\n\nGETLISTSROK\n");
                //  controller.GetListSrok(10);

                //  Console.WriteLine("\n\nALL\n");
                //  controller.All();

                //  Console.WriteLine("\n\nSortAndList\n");
                //  controller.SortAndList();
                //}
            }

            Computer PC1 = new Computer("Hp 310", 751.5, 5, 220, 3, "Intel core i5", "NVidea 980", 16384, 1);

            Console.WriteLine(PC1);

            bool Err = false;

            try
            {
                int zero     = 1;          //0/1
                int newprice = 100 / zero; //-100 err/100
                int countbuy = 5;          //10 err/5
                int countadd = 5;          //-5 err/5

                Console.WriteLine($"\nTry to make a new price on {PC1.name} {newprice} dollars.");
                PC1.NewPrice(newprice);

                Console.WriteLine($"\nWe will try to buy {countbuy} {PC1.name}");
                PC1.Buy(countbuy);

                Console.WriteLine($"\nWe will try to add {countadd} {PC1.name}");
                PC1.Add(countadd);
            }
            catch (PriceException exception)
            {
                Console.WriteLine("Error: " + exception.Message);
                Console.WriteLine("Method: " + exception.TargetSite);
                Console.WriteLine("Source: " + exception.Source);
                Err = true;
            }
            catch (BuyException exception)
            {
                Console.WriteLine("Error: " + exception.Message);
                Console.WriteLine("Method: " + exception.TargetSite);
                Console.WriteLine("Source: " + exception.Source);
                Err = true;
            }
            catch (AddException exception)
            {
                Console.WriteLine("Error: " + exception.Message);
                Console.WriteLine("Method: " + exception.TargetSite);
                Console.WriteLine("Source: " + exception.Source);
                Err = true;
            }
            catch (Exception exception) +
                {
                    Console.WriteLine("Error: " + exception.Message);
                    Console.WriteLine("Method: " + exception.TargetSite);
                    Console.WriteLine("Source: " + exception.Source);
                    Err = true;
                }
            finally
            {
                if (Err == true)
                {
                    Console.WriteLine("Errors processed.");
                }
                else
                {
                    Console.WriteLine("All right.");
                }
            }
            bool isError = false;

            Debug.Assert(isError); // проверяет, есть ли логическая ошибка при создании программы. Выбрасывает стек вызовов, если false
        }
Пример #11
0
 public void BuildCASE()
 {
     computer.Add("不起眼的機殼");
 }
 public void BuildCASE()
 {
     computer.Add("電競專用機殼");
 }
Пример #13
0
 /// <summary>
 /// 构建操作1
 /// </summary>
 public override void BuildCPU() => computer.Add("CPU By FirstBuilder");
Пример #14
0
 /// <summary>
 /// 安装显卡
 /// </summary>
 public virtual void BuildPartGraphicsCard()
 {
     computer.Add("组件集成显卡安装完毕");
 }