COP 2800 (Java Programming I) Project #6

 

Due: by the start of class on the date shown on the syllabus

Description:

Using TxtCrypt.java as an example, create a Java GUI applet that allows a user to encrypt any text as Pig Latin.  For example, the string "Java is very simple!" should be converted to the string "Avajay isway eryvay implesay!".  You may use either AWT or swing.

Requirements:

Write a Java applet called TxtCrypt.  This applet should allow anyone to convert any text into Pig Latin.  Your applet must provide a pair of TextArea components where the user can type in any text into the first, and see the encrypted results in the second.  The input text is called the plaintext, and the resulting Pig Latin is called the ciphertext.  You must provide the basic GUI and event handling.  This must include a button which when pressed displays the ciphertext for the currently displayed plaintext.  (You may add additional GUI components as you see fit.)

I have provided class PigLatin (view PigLatin class Java Docs), which is a class with a static method called encrypt.  (See below for the download link.)  This method takes a String as an argument and returns an encrypted, Pig-Latin-ized version of the argument as another String.  The method signature is:

    public class PigLatin
    {
        public static String encrypt ( String plainText )
        { ...
        }

        ...
    }

You only need the PigLatin.class file (which can be put in the same directory as your .java files, since it is in the default (nameless) package).

Make sure your applet is in the default, nameless package!  If using Eclipse, NetBeans, or some other IDE, you may find your applet was put into some package by default.  It is not possible for a class in any package to access classes in the default, nameless package.

To be turned in:

Email to me your Java source and your HTML files, by copy-and-paste (no attachments please!).

Send projects to .  Please use a subject such as Java I Project 6 Submission so I can tell which emails are submitted projects.  When you submit the project by email, the only files you should send are your TxtCrypt Java source file(s) and your HTML file.  Do not email any class files, or PigLatin.java or PigLatin.class

However, if your applet uses any media files (for the creative extras part of the assignment), you can submit them as attachments using my alternate email address.  You should send this email to waynepollocklive@yahoo.com.  (Email sent to my regular email address that contains attachments may be discarded by the HCC mail server!)

Send project questions to .  Please use a subject such as "Java Text Crypt Project Questions" so I can tell which emails are questions about the project.

Please review Submitting Assignments and Project Grading Criteria from your class syllabus for further details.

Sample Output:

The model solution applet TxtCrypt.java is available for you to play with and download (the .class file, not the source file). 

You might also want to download PigLatin.class and the HTML file I use to display the applet.  If so, click on the link above and then chose "Save As" from the File menu.

Hints:

Don't worry too much about how the PigLatin class works.  Just assume it works and use it as is.  (If you have extra time and would like to know how it works, I'd be happy to explain during office hours.)

Both TextField and TextArea share a lot of common functionality.  Following best object-oriented design principles both of these classes extend (inherit from) a common parent class.  When trying to find useful methods for TextArea, be sure to look at the inherited methods too.

You should naturally use your own name, not mine in the applet credits.

It is quite easy to use multiple classes in an Applet.  If you want you can use PigLatin.class directly, or you can create and use a Jar file.  (Jar files are like zip files, that contain several .class files in a single compressed archive.)  In practice the most common deployment method is to use a jar file.  (This is covered late in our course.) 

Part of your grade is based on your creative extras you put into the project.  For example, my applet has a good color scheme, a clear button and a little humor.  (Some say very little!)  Your applet may contain pop-up help, a menubar, graphics, animation, sound, and so on.  For credit your creative extras must be your own, be useful and/or decorative in a text encryption applet, and work correctly.  (Adding a calculator, or a button to change the colors, would not be considered useful in this case.  A joke wouldn't be considered creative since I used one already, but feel free to have one anyway if it's funny.)

Be aware that applets have security restrictions on what they can do.  No untrusted applet can access the clipboard (or other resources), or read or write files on the local system.  (It is possible to create a signed applet, which can then be granted extra privileges.  But this topic is not covered until the advanced Java course.)

You program should be easy to read and be well commented.  Don't forget to include your name at the top of each file.

Ask me for help if you get stuck!