October 2001
Intermediate to advanced
640 pages
18h 58m
English
This appendix gives the full programs for the eight-queens puzzle discussed in Chapter 6.
(* Eight-Queens Puzzle in Object Pascal Written by Tim Budd, Oregon State University, 1996 *) Program EightQueen; type Queen = object (* data fields *) row : integer; column : integer; neighbor : Queen; (* initiaiization *) procedure initialize (col : integer; ngh : Queen); (* operations *) function canAttack (testRow, testColumn : integer) : boolean; function findSolution : boolean; function advance : boolean; procedure print; end; var neighbor, lastQueen : Queen; i : integer; procedure Queen.initialize (col : integer; ngh : Queen); begin ...
Read now
Unlock full access