Assignment 1 for CSE 373 (Autumn 2008)
Due Sunday, October 5, at 11:45 PM.
CSE 373: Data Structures and Algorithms
The University of Washington, Seattle, Autumn 2008
Using the resources provided and guidelines below, implement a Java program that demonstrates the operation of a stack using digital photographs as data. Your program will accept three input strings, and create a folder containing a set of web pages (using HTML markup). One of your three input strings will be the name of a folder containing images. After your program is working, provide details on two test runs. In the first run, use the given data for EXAMPLE1. In the second run, EXAMPLE2, create your own data.
 
A sample command-line string to run your program is this:
 
java ImageStacking EXAMPLE1-commands.txt my-images EXAMPLE1-output

 
Input file format: There are three strings passed as arguments to the main method of the program. The first string is the name of a file of commands (PUSH and POP commands) to be performed. The second string is the name of a folder containing images. The third string is the name of an output folder that your program will create. For the format of the file of commands, see the sample data file "test-commands.txt" in the zip archive ImageStacking-Sample-Data.zip. Each line in this file starts with either "PUSH" or "POP". If it is "PUSH", then there is a space and then the name of an image file. This file must exist in the folder of images named by the second argument.
 
Output file format: Besides the output folder being created, there will be one HTML page (a text file) created corresponding to each command in the input file. For the format of the output pages, see the output folder in the zip archive ImageStacking-Sample-Data.zip.
 
Requirements:
  • Correctly process all the commands in the command file, whose name is given in input argument 1.
  • Create an output folder using the given name input argument 3.
  • Within the output folder, create n html pages, where n is the number of commands in the command file. Each web page should show the state of the stack after the corresponding command has been executed. Each web page except the last should have a redirect indication that will cause the next web page to be loaded after a delay of 500 ms.
For more details on these requirements, follow the practice illustrated in the ImageArray.java program provided below (except for the fact that you'll implement a stack with PUSH and POP instead of an array with INSERT-AT and DELETE-AT).
 
Resources Provided: A similar application called ImageArray.java is available to use as starting code. It is provided here as the zipped up version of an Eclipse 3.4 project. A sample command file and images are included, as is the output. Here it is: ImageArray.zip. Also, here is some sample input and output for the ImageStacking assignment program. It's in ImageStacking-Sample-Data.zip.
 
Hints and suggestions:
  • If this is your first time using Eclipse, then be sure to create a "Hello World" project and get that working before attempting to get the sample program working. A "Hello World" project involves creating a short program that does nothing more than print out the string "Hello World".
  • Get the ImageArray program working in an Eclipse project prior to coding anything for the ImageStacking program.
  • Copy your working ImageArray project by selecting it in the package explorer and typing Ctrl-C. Then paste to create a copy of the project. Rename the copy to be ImageStacking, using a refactoring operation from the menu.
  • Make sure the copy works (implementing the ImageArray) functionality, and then proceed to start changing those parts of the code that you need to in order to create the ImageStacking application.
  • Doing this project is a lot easier than it might seem. That is because all the hard parts of creating this application (reading and parsing input files, writing HTML to display a set of images, etc.) have already been done for you. They are provided in the ImageArray application. You'll mainly be getting used to Eclipse in this assignment.
  • As a suggestion, learn to use JavaDoc-style commenting. The ImageArray.java file uses it. You might want to try running JavaDoc on it (from within Eclipse) to see the documentation it produces from the source file.
  • If you would like to follow some online tutorials about Java, there are several available at Sun Microsystems' Java web site.

 
Turning in your work: Turn in a zip archive containing: (1) your code, (2) input and output data files for two runs. The first run will be using the provided images and a new command file: EXAMPLE1-commands.txt, and the second run will use five images that you provide (don't use any of the given ones) and a new file of commands that you name "EXAMPLE2-commands.txt".
Note that the graders may also test your program on other inputs than the ones being made available to you.
Turn in your assignment using Catalyst CollectIt.
 
After you have turned in the assignment, please provide feedback via this WebQ questionnaire.

updated Sept. 25, 2008.