HW#3 --- last modified
January 01 1970 00:00:00..
Solution set.
Due date: Mar 22
Files to be submitted:
TicTacToe.java
Purpose:
To gain practice in verifying forms
using
Javascript. To gain practice
writing programs that maintain transaction state.
Specification:
For
this
homework you will write a servlet that lets the user play tic-tac-toe.
If you do not know what tic-tac-toe is do a Google search on it.
You will use hidden variables to maintain the current state of the game
and you will verify any form data that is to be sent via Javascript before
sending it. All forms for this assignment should use the Post method.
When first accessed your tic-tac-toe servlet should return
a page which says Welcome to the Tic-tac-toe game! Would you like to go
first? What follows is then a text input field in which the user can
type up to three characters and the a submit button. You should
use Javascript to verify that the user enters one of something which when
converted to lower case looks like y, yes, n, no before sending this data
to the server. Turn taking then takes place to play a game between the user
and the server. You should try to draw the tic-tac-toe board as
realistically as possible using tables. The servlet is allowed to move
any way you want as long as it always makes legal moves. When it is
the user's turn, the user should see a game board and beneath it two texts
fields and a submit button. One field should say x before it and the other
should say y. The user then can enter the x and y coordinate of his move and
click submit. At this point, Javascript is used to check to make sure
the x and y values are in the range of the board (For example, 4 as
an x value will not be on the board). It should also check that
the move is a legal move. Your program should
detect when the game end and inform the user and ask if he wants to play again.
Point Breakdown
Departmental coding guidelines for Java followed | 1pt |
Javascript used correctly to verify yes/no intro form data before sending it |
1pt |
Turn taking works correctly | 1pt |
Servlet only makes legal moves | 1pt |
Board drawn with tables | 1pt |
Javascript used to verify user moves before sending
them. | 1pt |
Servlet cannot move twice in a row without a user move | 1pt |
Form data uses hidden fields to preserve game state | 1pt |
Post method is used. | 1pt |
Servlet detects is someone wins and informs user. Then
offers another game. | 1pt |
Total | 10pts |
1. One additional bonus point will be given if you can make all of the
HTML pages your servlet generates XHTML 1.0 transitional compliant.
2. One additional bonus point will be given if your program plays perfect
tic-tac-toe. (i.e., never loses)
|