This is a tentative versions. Check this file regularly
for updates.

CSE 8B Spring 2001
Homework #7

Required reading: Savitch text Chapters 13-14.

Turn in due date: Friday, June 1
Interview due date: Wednesday, June 6

Note: No interviews will be given after June 8! (June 8 is the last day of classes)

Note: You can do this and take an interview without turning in the assignment, as long as it is before the
turnin deadline (and until the deadline is announced it is definitely before the deadline).

Programming:
You may work in teams of two students, but once you form a team, you cannot change the team for this assignment. You may work alone if you prefer.

Write a program for editing text files. Your program will have a GUI interface created using Swing.

It will have the following functionality:
It can perform one task at a time. The tasks are:

1. Delete Extra Blanks: compress all strings of two or more blanks down to a single blank. The edited version goes in a new file. The original file is unchanged.

2. Correct Capitalization: This merely insures that all sentences begin with an uppercase letter. Define the start of a sentence as the first nonwhitespace character following either a period (.), question mark (?), or exclamation mark (!). (Use your discretion for handing cases where the first nonwhitespace character after the punctuation is not a letter.) The edited version goes in a new file. The original file is unchanged.

3. Make a copy of the file.

4. Delete the file.

There is a menu with a menu item for each task, plus one menu item labeled "Clear all fields" that clears the two text fields, plus an item labeled "Exit" that ends the programs, and plus a menu item labeled "Help" that produces a help window. There is also a button labeled "Help" that produces the same help window.

Choosing Exit on the menu or clicking the close-window button have the same effect, namely ending the program.

The Help window simply displays some text telling the user how to use the program. The Help window has an "OK" button that makes the help window go away.

Your GUI will have two text fields for file names, labeled Source File and Destination File.

The user types a file name in the Source File field and chooses a task from the menu.

For task 4 a second window pops up asking the user if he/she is sure he/she wants to delete the file. If the user clicks "Yes", the file is deleted. If the user clicks "No", then they are returned to the main window. If the file does not exists, a window pops up telling the user that the file does not exist.

For tasks 1, 2, and 3 a second window pops up asking for the name of the file to receive the corrected file or the copy of the file. The user is told to type the file name in the Destination File field in the main window and press the "OK" button (in this second window). If the user follows instructions the destination file is created.

If the user ever gives the name of an existing file for a destination file, then a warning window appears that says something like: "The file blabla exists. Proceeding will destroy the old contents of this file." There are two buttons in the warning window labeled Proceed and Cancel which cause the obvious actions.

Notes:
You may use JOptionPane if you wish (or you can do this assignment without JOptionPane).

The help window instructions need not be very long.

When asked to delete a file, your program is not expected to check to see if the file is a text file or not.

When asked to copy a file, you can assume the file name given by the user is a text file. Your program does not need to check to see if the file is a text file or not.