Homework 1
CS320, Fall 2008

Due: Wednesday, October 8

Please upload your files to CSNS. The files should include all the source code, documentation (if any), and an HTML file hw1.html, which contains a link to your application on the CS3 server. Note that file uploading will be disabled automatically after 11:59PM of the due date, so please turn in your work on time.



This quarter we are going to implement an online betting game called BetNBA, which allows users to bet on the results of NBA basketball games. Of course, there won't be any money involved, only bragging rights.

BetNBA supports two types of users: admin users and regular users. An admin user can create games for the regular users to bet on, and an admin user is also responsible for entering the results of games after the games are played. A regular user can bet on a game before the game is played by choosing the winner of the game. If the user is correct, the user gets 1 point; if the user is wrong or the user didn't bet on that game, the user gets no point. At the end of a basketball season, the users with the most points will be declared the winners of BetNBA.

For this assignment, you are going to implement the admin interface of BetNBA. The admin interface consists of three pages, as described below. You may use one or more servlets, or a combination of servlets and HTML pages to create the admin interface.

1. (30pt) The Game List page shows the list of the games that are currently in the system:

BetNBA - Admin
Game Team 1 Team 2 Date Winner
1 Timberwolves Hornets 9/20/2008 Hornets
2 Magic Celtics 9/22/2008 Celtics
3 Heat Warriors 9/25/2008 Heat
4 Lakers Pacers 10/6/2008 Enter Result
5 Trail Blazers Knicks 10/7/2008 Enter Result
Add Game

2. (30pt)  When an admin user clicks on the Add Game link, the application shows the Add Game page where the user can add a new game:

BetNBA - Add Game
Team 1:
Team 2:
Date (mm/dd/yyyy):

The application should check the input to make sure the information about the game is valid. In particular, a) the names of the teams and the date cannot be empty, b) the names of the teams cannot be the same, and c) the date is in the format of mm/dd/yyyy, e.g. 09/29/2008. If the input is valid, a new game is created and the user is redirected to the Game List page where the new game is displayed; otherwise the Add Game page will be displayed again with an error message telling the user to re-enter the information.

3. (30pt)  When an admin user clicks on the Enter Result link, the application shows the Game Result page where the user can choose the winner of game. For example:

BetNBA - Game Result
The winner of Game 4 is:

After the user clicks the Save button, the user is redirected to the Game List page. Note that after the result of a game is entered, the Enter Result link in the Winner column of the game should be replaced with the name of the winning team.