getYCoOrdinate() public method

public getYCoOrdinate ( ) : int
return int
示例#1
0
 public void removeQueenFrom(XYLocation l)
 {
     if (squares[l.getXCoOrdinate()][l.getYCoOrdinate()] == 1)
     {
         squares[l.getXCoOrdinate()][l.getYCoOrdinate()] = 0;
     }
 }
示例#2
0
        public override bool Equals(Object o)
        {
            if (null == o || !(o is XYLocation))
            {
                return(base.Equals(o));
            }
            XYLocation anotherLoc = (XYLocation)o;

            return((anotherLoc.getXCoOrdinate() == xCoOrdinate) && (anotherLoc
                                                                    .getYCoOrdinate() == yCoOrdinate));
        }
        public int evaluateManhattanDistanceOf(int i, XYLocation loc)
        {
            int retVal = -1;
            int xpos = loc.getXCoOrdinate();
            int ypos = loc.getYCoOrdinate();
            switch (i)
            {

                case 1:
                    retVal = Math.abs(xpos - 0) + Math.abs(ypos - 1);
                    break;
                case 2:
                    retVal = Math.abs(xpos - 0) + Math.abs(ypos - 2);
                    break;
                case 3:
                    retVal = Math.abs(xpos - 1) + Math.abs(ypos - 0);
                    break;
                case 4:
                    retVal = Math.abs(xpos - 1) + Math.abs(ypos - 1);
                    break;
                case 5:
                    retVal = Math.abs(xpos - 1) + Math.abs(ypos - 2);
                    break;
                case 6:
                    retVal = Math.abs(xpos - 2) + Math.abs(ypos - 0);
                    break;
                case 7:
                    retVal = Math.abs(xpos - 2) + Math.abs(ypos - 1);
                    break;
                case 8:
                    retVal = Math.abs(xpos - 2) + Math.abs(ypos - 2);
                    break;

            }
            return retVal;
        }
示例#4
0
	public int getValueAt(XYLocation loc) {
		return getValueAt(loc.getXCoOrdinate(), loc.getYCoOrdinate());
	}
示例#5
0
	public void testXYLocationAtributeSettingOnConstruction() {
		XYLocation loc = new XYLocation(3, 4);
		Assert.AreEqual(3, loc.getXCoOrdinate());
        Assert.AreEqual(4, loc.getYCoOrdinate());
	}
示例#6
0
 //
 // PRIVATE METHODS
 //
 private bool withinRadius(int radius, XYLocation agentLocation,
         XYLocation objectLocation)
 {
     int xdifference = agentLocation.getXCoOrdinate()
             - objectLocation.getXCoOrdinate();
     int ydifference = agentLocation.getYCoOrdinate()
             - objectLocation.getYCoOrdinate();
     return Math.sqrt((xdifference * xdifference)
             + (ydifference * ydifference)) <= radius;
 }
示例#7
0
 public bool queenExistsAt(XYLocation l)
 {
     return (queenExistsAt(l.getXCoOrdinate(), l.getYCoOrdinate()));
 }
示例#8
0
 /**
  * Moves the queen in the specified column (x-value of <code>l</code>) to
  * the specified row (y-value of <code>l</code>). The action assumes a
  * complete-state formulation of the n-queens problem.
  * 
  * @param l
  */
 public void moveQueenTo(XYLocation l)
 {
     for (int i = 0; i < size; i++)
         squares[l.getXCoOrdinate()][i] = 0;
     squares[l.getXCoOrdinate()][l.getYCoOrdinate()] = 1;
 }
示例#9
0
 public void addQueenAt(XYLocation l)
 {
     if (!(queenExistsAt(l)))
         squares[l.getXCoOrdinate()][l.getYCoOrdinate()] = 1;
 }
示例#10
0
 public bool isSquareUnderAttack(XYLocation l)
 {
     int x = l.getXCoOrdinate();
     int y = l.getYCoOrdinate();
     return (isSquareHorizontallyAttacked(x, y)
             || isSquareVerticallyAttacked(x, y) || isSquareDiagonallyAttacked(
             x, y));
 }
示例#11
0
 public int getNumberOfAttacksOn(XYLocation l)
 {
     int x = l.getXCoOrdinate();
     int y = l.getYCoOrdinate();
     return numberOfHorizontalAttacksOn(x, y)
             + numberOfVerticalAttacksOn(x, y)
             + numberOfDiagonalAttacksOn(x, y);
 }