Clone() 공개 메소드

public Clone ( ) : Object
리턴 Object
예제 #1
0
        private IntPair[] GenerateRandomTestCase(int largeBoxRelativePos)
        {
            IntPair smallBoxPos = new IntPair(rnd.Next(BoxTrialCase.BASE_RESOLUTION),
                    rnd.Next(BoxTrialCase.BASE_RESOLUTION));

            IntPair largeBoxPos = (IntPair)smallBoxPos.Clone();
            switch (largeBoxRelativePos)
            {
                case 0:
                    largeBoxPos.AddX(5);
                    break;
                case 1:
                    largeBoxPos.AddY(5);
                    break;
                case 2:
                    if (rnd.NextDouble() > 0.5)
                    {
                        largeBoxPos.Add(3, 4);
                    }
                    else
                    {
                        largeBoxPos.Add(4, 3);
                    }
                    break;
            }

            if (largeBoxPos.X > BoxTrialCase.BOUNDS)
            {
                largeBoxPos.AddX(-BoxTrialCase.BASE_RESOLUTION);

                if (0 == largeBoxPos.X)
                {
                    largeBoxPos.Add(1);
                }
            }
            else if (BoxTrialCase.BOUNDS == largeBoxPos.X)
            {
                largeBoxPos.AddX(-1);
            }
            else if (largeBoxPos.X == 0)
            {
                largeBoxPos.AddX(1);
            }

            if (largeBoxPos.Y > BoxTrialCase.BOUNDS)
            {
                largeBoxPos.AddY(-BoxTrialCase.BASE_RESOLUTION);

                if (0 == largeBoxPos.Y)
                {
                    largeBoxPos.AddY(1);
                }
            }
            else if (BoxTrialCase.BOUNDS == largeBoxPos.Y)
            {
                largeBoxPos.AddY(-1);
            }
            else if (0 == largeBoxPos.Y)
            {
                largeBoxPos.AddY(1);
            }
            return new IntPair[] { smallBoxPos, largeBoxPos };
        }
예제 #2
0
        private IntPair[] GenerateRandomTestCase(int largeBoxRelativePos)
        {
            IntPair smallBoxPos = new IntPair(rnd.Next(BoxTrialCase.BASE_RESOLUTION),
                                              rnd.Next(BoxTrialCase.BASE_RESOLUTION));

            IntPair largeBoxPos = (IntPair)smallBoxPos.Clone();

            switch (largeBoxRelativePos)
            {
            case 0:
                largeBoxPos.AddX(5);
                break;

            case 1:
                largeBoxPos.AddY(5);
                break;

            case 2:
                if (rnd.NextDouble() > 0.5)
                {
                    largeBoxPos.Add(3, 4);
                }
                else
                {
                    largeBoxPos.Add(4, 3);
                }
                break;
            }

            if (largeBoxPos.X > BoxTrialCase.BOUNDS)
            {
                largeBoxPos.AddX(-BoxTrialCase.BASE_RESOLUTION);

                if (0 == largeBoxPos.X)
                {
                    largeBoxPos.Add(1);
                }
            }
            else if (BoxTrialCase.BOUNDS == largeBoxPos.X)
            {
                largeBoxPos.AddX(-1);
            }
            else if (largeBoxPos.X == 0)
            {
                largeBoxPos.AddX(1);
            }

            if (largeBoxPos.Y > BoxTrialCase.BOUNDS)
            {
                largeBoxPos.AddY(-BoxTrialCase.BASE_RESOLUTION);

                if (0 == largeBoxPos.Y)
                {
                    largeBoxPos.AddY(1);
                }
            }
            else if (BoxTrialCase.BOUNDS == largeBoxPos.Y)
            {
                largeBoxPos.AddY(-1);
            }
            else if (0 == largeBoxPos.Y)
            {
                largeBoxPos.AddY(1);
            }
            return(new IntPair[] { smallBoxPos, largeBoxPos });
        }