コード例 #1
0
        static void Main(string[] args)
        {
            Group          group = new GroupSum();
            FigureCircle   fc    = new FigureCircle(1);
            FigureSquare   fs    = new FigureSquare(3);
            FigureTriangle ft    = new FigureTriangle(3, 4, 5);

            Group gr = new GroupSum();

            gr.Add(fs);

            Console.WriteLine(fc.Measure());
            Console.WriteLine(fs.Measure());
            Console.WriteLine(ft.Measure());

            Console.WriteLine(gr.Measure());

            group.Add(fc);
            group.Add(fs);
            group.Add(ft);
            group.Add(gr);


            Console.WriteLine(group.Measure());
        }
コード例 #2
0
        public void Measure_SumItems_OnlyFigures()
        {
            FigureSquare square   = new FigureSquare(3);
            FigureCircle circle   = new FigureCircle(3);
            GroupSum     groupSum = new GroupSum();

            groupSum.Add(square);
            groupSum.Add(circle);
            float measureItems = square.Measure() + circle.Measure();
            float measureGroup = groupSum.Measure();

            Assert.AreEqual(measureItems, measureGroup);
        }
コード例 #3
0
        public void Measure_MultiplyItems_FiguresAndOtherGroup()
        {
            FigureSquare   square        = new FigureSquare(2);
            FigureCircle   circle        = new FigureCircle(2);
            FigureTriangle triangle      = new FigureTriangle(3, 4, 5);
            GroupSum       groupSum      = new GroupSum();
            GroupMyltiply  groupMyltiply = new GroupMyltiply();

            groupSum.Add(triangle);
            groupSum.Add(square);
            groupMyltiply.Add(groupSum);
            groupMyltiply.Add(circle);
            float measureItems = groupSum.Measure() * circle.Measure();
            float measureGroup = groupMyltiply.Measure();

            Assert.AreEqual(measureItems, measureGroup);
        }