Chapter 6
A Case Study: The Eight-Queens Puzzle
This chapter presents the first of several case studies (or paradigms, in the original sense of the word) of programs written in an object-oriented style. The programs in this chapter will be rather small so we can present versions in several different languages. Later case studies will be presented in only one language.
After first describing the problem, we will discuss how an object-oriented solution would differ from another type of solution. The chapter then concludes with a solution written in each language.
6.1 ⊡ The Eight-Queens Puzzle
In the game of chess, the queen can attack any piece that lies on the same row, on the same column, or along a diagonal. The eight-queens is a classic logic ...
Get An Introduction to Object-Oriented Programming, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.