Programming Assignment Checklist: Hamming Codes

Frequently Asked Questions

What are the goals of this assignment? To Learn about error-correcting codes; to learn to program in a machine language; and to appreciate the programming and debugging advantages of a structured programming language like Java over machine language!

I can't launch the Java Web Start version of the Visual X-TOY simulator. Any ideas? The program requires something called Web Start. When you installed Java initially, this was included. However, the last Windows security patch I applied broke this. If this happens to you, go to java.com and click the Get It Now button.

How do I format the TOY output? You can't. Just print one integer per line (0000 or 0001).

TOY.java doesn't read in some of my instructions. Any ideas? Be sure that you follow the required format XX: XXXX. Check for duplicated line numbers and using the letter O instead of the number 0.

My program prints out the right answer, but then I get java.lang.NumberFormatException: null. What could be wrong? You are probably trying to read from standard input, even though it is empty. Be sure that your TOY program terminates when it encounters FFFF.

TOY Simulators

To simulate the execution of your program on a TOY machine, use either the bare-bones TOY.java or the full-blown Visual X-TOY simulator.

Input, Output, and Testing

Input. Copy the hamming directory from the COS 126 ftp site to your computer.

Execution.  To redirect standard input from a file, execute your programs with:

% java TOY encode.toy < encode1.txt
% java TOY decode.toy < decode1.txt
If you are using the Java X-TOY simulator, you can use Mode -> Load File to Stdin to redirect standard input from a file.

Testing.  The most complete way to test your TOY programs is to encode and decode all possible inputs. Use the files encode16.txt and encode16.txt.ans to debug encode.toy: the first file contains all possible 4-bit inputs, the second contains the answer. We group the answer 7 integers per line even though the TOY machine outputs only 1 per line. Use the files decode128.txt and decode128.txt.ans to debug decode.toy: the first file contains all possible 7-bit inputs, the second contains the answer.

Reference solutions.   As a special bonus, we provide Java source code HammingEncoder.java and HammingDecoder.java. for the two programs. You may wish to examine this code and use it to develop your TOY programs.

Debugging Tips

Here are some debugging hints that may help you out.

Enrichment