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

Initialization

Initialization will set each queen to point to a neighbor, and set column value. C++ version is shown:


main() {
	Queen * lastQueen = 0;

	for (int i = 1; i <= 8; i++)
		lastQueen = new Queen(i, lastQueen);
	
	if (lastQueen->first()) 
		lastQueen->print();
}

Queen::Queen (int col, Queen * ngh)
{
	column = col;
	neighbor = ngh;
	row = 1;
}

Intro OOP, Chapter 5, Slide 8