23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

We give a complete <strong>Java</strong> class for ma<strong>in</strong>ta<strong>in</strong><strong>in</strong>g a Tic-Tac-Toe board for two<br />

players <strong>in</strong> Code Fragments 3.10 <strong>and</strong> 3.11. We show a sample output <strong>in</strong> Figure 3.9.<br />

Note that this code is just for ma<strong>in</strong>ta<strong>in</strong><strong>in</strong>g the tic-tac-toe board <strong>and</strong> register<strong>in</strong>g<br />

moves; it doesn't perform any strategy or allow someone to play tic-tac-toe<br />

aga<strong>in</strong>st the computer. Such a program would make a good project <strong>in</strong> a class on<br />

Artificial Intelligence.<br />

Code Fragment 3.10: A simple, complete <strong>Java</strong> class<br />

for play<strong>in</strong>g Tic-Tac-Toe between two players.<br />

(Cont<strong>in</strong>ues <strong>in</strong> Code Fragment 3.11.)<br />

161

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!