MIDTERM
CS320, Fall 2008


Please upload your files to CSNS. The files should include all the source code, documentation (if any), and an HTML file midterm.html which contains a link to your application on the CS3 server. Note that file uploading will be disabled automatically after 9:10PM, and late submission will not be accepted.

[Problem Description]

In this exam you are going to implement a web application that allows a user to search the inventory of a used car dealership. The inventory of the dealership is stored in a text file. Each line in the file contains the information about one car, in the format of "Year,Make,Model,Price,Color,Mileage" (Year, Price, and Mileage are integers). You may use the sample file cars.txt to test your application. This file is also available on the CS3 server at /tmp/cars.txt .

Your application  must use either Model 1 or MVC architecture as discussed in class. No matter which architecture you choose, the application must meet the following requirements:

[Implementation]

The application should consist of a Search page and a Results page.

The Search page displays a form that allows a user to select the field to search and enter a search term:

Depending on the selected search field, the application performs either a case-insensitive substring search or a numerical range search. Specifically, if the selected search field is Make, Model, or Color, the results should include all the cars whose selected search field contains the search term as a substring. For instance, if a user searches for "cobalt" in the Model field, the following two cars should be in the results:

If the search field is Year, Price, Mileage, the results should include all the cars whose selected search field are within the given range. For instance, if a user searches for "2005-2006" in the Year field, the results should be:

Note that for Year, Price, Mileage, the search term is always in the form of "integer1-integer2", where integer1<=integer2, e.g. "2005-2006" or "10000-15000". For simplicity, you may assume that the input is always in the right form, i.e. there is no need to do input validation.

The Results page displays the search results in a table like the following:

Found 2 car(s) that meet your search criteria:

Year Make Model Price Color Mileage
2006 Chevrolet Cobalt LS $9986 White 41668
2008 Chevrolet Cobalt LT $12986 Gray 17218

Search Again

where the link will take the user back to the Search page. If no results are found, instead of displaying an empty table, it should display

Found no car that meets your search criteria.

Search Again

[Grading Criteria]