Java Reference
In-Depth Information
15.8 Exercises
1. Transform the calculator program from Chapter 12 into a Java Applet. The applet
should appear inside a web browser without a new window being opened. You can use
the HTML file that is generated by NetBeans.
2. Create a Java Applet that converts Celsius to Fahrenheit. The applet should appear
inside a web browser without a new window being opened. You can use the HTML
file that is generated by NetBeans.
3. Create a Java Applet for the Breakout game. The applet should appear inside a web
browser without a new window being opened. Create your own HTML file.
15.9 Lab
Modify the Tic-Tac-Toe game by making the AI stronger. See if you can make the
computer player so good that the program never loses.
15.10 Project
Extend the Tic-Tac-Toe game to work on a 15 x 15 board, where you need a line of
5 characters to win. Your AI will first check if the computer can win. Then it will check
if the human player can be prevented from winning on the next move. Next, check if the
computer can make a line of 4 characters that is open at both ends and that can be used to
win the game on the next move. If such a line does not exist, your program should search
to see if it can prevent the human player from creating such a line and so on. Your program
does not need to be perfect, that is, it is expected that it will lose some games. Once the
mouse cursor hovers over an empty square of the board, make the square green in order to
indicate that the human player can play there. Display an appropriate message when the
game ends. In the unlikely event that the board becomes full without anyone getting a line
of 5 characters, the game should be declared a draw.
 
Search WWH ::




Custom Search