Introduction to OOP: Chapter 5: A Case Study : Eight Queens [next] [previous] [audio] [real] [text]

Can Attack


function canAttack(r, c)
	if r = row then
		return true
	cd := column - c;
	if (row + cd = r) or (row - cd = r) then
		return true;
	return neighbor.canAttack(r, c)
end
For a diagonal, the difference in row must equal the difference in columns.
Intro OOP, Chapter 5, Slide 12