Project #8 (Terp Idol)

CMSC 132

Due Date: Tuesday May 8, 6:00 pm

Object-Oriented Programming II

Type of Project: Closed

Spring 2007


Objective

This project has several objectives.  Those objectives are:

This project is considered a closed project.  Make sure you read the open/closed policy before continuing working on this project.

Project Clarifications

Any clarifications or corrections associated with this project will be available at: clarifications.html

Overview

For this project you will complete the following tasks:

Javadoc documentation for this project can be found at CMSC 132 Terp Idol.

Your project will be graded as follows:

Public JUnit tests                                      45 %

Release JUnit tests                                  50 %

Style                                                            5 %

For this project:

Specifications

Terp Idol Rules

The Terp Idol contest is run in a similar manner as American Idol.

Client-Server Programming Model

Your code must use a client-server programming model, where clients initiate contact with the server to request some service.  The server waits for incoming client requests and sends back the appropriate response. Your task is to implement client and server classes that we can use to run online voting & information gathering for a Terp Idol contest. To do so you must implement code in the Contest, Server, CommandProcessor, Client, Voter, and Judge classes. The strings representing the messages between clients and the server are defined as static final in the Const class, and may be used in other classes using "import static terpIdol.Consts.*;". Setting up the contest will roughly require the following steps

Set up server

  1. Use the Contest class to create a Server object with a CommandProcessor for processing requests.
  2. Server creates a ServerSocket, and the port number assigned to ServerSocket is stored in Contest class.
  3. Run Server in a separate daemon thread. Get ready to accept incoming Client connections.
  4. Server should handle incoming Client connections in separate threads (to support multiple Clients concurrently). 

Set up clients 

  1. Use the Contest class to create Client objects with Sockets connecting to the port number of the ServerSocket.
  2. Clients may be Judges or Voters, each with different types of requests as shown in the table below.

Handle client-server requests

  1. A client can send requests (in the form of strings) to the Server through its Socket connection
  2. Server examines request from client. Two requests (PING, DISCONNECT) are handled directly
  3. Other requests are passed to the CommandProcessor
  4. The response for each request (if any) is passed back to the client as a string
  5. Server continues to serve Client until DISCONNECT is received. Server then goes back to waiting for clients.

The list of requests the contest server must process are shown in the following table:

Sent by Client Sends Server Returns Server Sends REQUEST FAILED if
Client PING SERVER RUNNING <date>  
DISCONNECT <none>  
<unknown request code> INVALID REQUEST <unknown code>  
Voter CONTESTANTS CONTESTANTS <names on separate lines>  
VOTE <name> VOTE <name> REQUEST FAILED <name> if no such contestant
LOOKUP <name> LOOKUP <line in data file for name> REQUEST FAILED if <name> not in file
IMAGES <url> IMAGES <URLs of images on separate lines> REQUEST FAILED if <url> not valid file/web page
Judge INVITE <name> INVITE <name> REQUEST FAILED <name> if already contestant 
TALLY TALLY <names & # votes, each name on separate line>  
NEW ROUND NEW ROUND <name of eliminated contestant> REQUEST FAILED if no contestants left

To recognize images, the server will search through the html code of the specified web page, looking for entries starting with "<img src="  where any number of spaces and options (e.g. border) may exist in between img and src.   An image is represented by the string following "src=", ending in a quotation mark. For instance, the following text are examples of possible image URLs for which you will be searching.

                <img src="http://i.cnn.net/cnn/images/1.gif">    <img src="file:/C:/eclipse/workspace/p8/web/2.gif">

The server will return a list of URLs of images found.  A URL is defined as one that starts with "http:" or "file:" and which provide the exact location of the image so that we can cut-and-paste the URL in a browser and actually see the image.  For this project you don't have to worry about sites that may use uppercase letters for img or src in the html code. 

Feel free to add any private instance variables and methods you understand are necessary.  You may not add any additional public methods.  Also, feel free to add any support classes you might need.

Java Construct Requirements

                                       throw new IllegalArgumentException("Your message here");

Style Requirements

Submission

Submit your project using the submit project option associated with Eclipse. 

Academic Integrity

Please make sure you read the academic integrity section of the syllabus so you understand what is permissible in our programming projects.  We want to remind you that we check your project against other students' projects and any case of academic dishonesty will be referred to the University's Office of Judicial Program

Web Accessibility