CIS 180: Object-Oriented Programming
Homework #9

Due November 25, 2009

Objectives

The objectives of this homework are:

Problem Statement

In this assignment you will be implementing an application that can encrypt and decrypt text using the rot13 cipher. This is a very simple (and not very secure) way of encrypting text. Imagine that the alphabet is aranged in a circle as shown below:

Each character is encrypted by rotating 13 positions clockwise. For example, the letter 'a' is replaced by the letter 'n', and the letter 'r' is replaced by the letter 'e'. Notice that the encoding is symmetric, since the alphabet has 26 letters. For example, rotating 13 positions from 'n' we get back to 'a'.

Uppercase letters are similarly encrypted by rotating 13 positions. Other characters (numerals, punctuation marks, etc.) are left unencrypted.

Your application should display a window with a scrollable text area where the user can enter text and a button to click to encode or decode the text in the text area. The user can type or paste text into the text area and click the button to encode or decode it.

After pasting some text into the text area, the application should look similar to the following (before and after clicking the Encode/Decode button:

Design

Your application should consist of a single class called Cipher. You should have a method to encrypt a single character, and a method to encrypt a String: In addition, you should have whatever fields and methods you need to implement the user interface. As usual, document your design with a UML class diagram.

Implementation

Start by implementing and testing the method to encrypt a single character. Once that is working correctly, implement and test the method to encrypt a String. Finally, add the grapical user interface.

Hints

What to turn in

When your assignment is complete, add some comments to the beginning of the java source code explaining any problems you encountered in completing the assignment and describing any bugs in your solution. Undocumented bugs are worse than documented bugs. If you have undocumented bugs we will assume that you did an inadequate job of testing your code, and you will lose additional points.

Submit your source code file (Cipher.java) as an email attachment to: ttao@umassd.edu. Use the subject line CIS-180 HW#9 in your email. Your UML class diagram may either be submitted in class (hardcopy), or included as a second email attachment (softcopy) with your source code.

There will be a 10% penalty for assignments received after the due date. Assignments will not be accepted more than one week past the due date.