import java.util.*; import javax.swing.*; public class HammingClient { private static boolean evenParity; //The Input Message private static String text_IN; //The Decoded Message private static String text_OUT; //The Hamming Code-Words private static ArrayList buffer; public static void main(String[] args) { evenParity = (new Random()).nextBoolean(); enterText(); //Enter a text message encodeText(); //Create its Hamming-encoding sendText(); //Create some single-bit errors decodeText(); //Interpret the Hamming code //Display the entered and received texts System.out.println(text_IN + "\n" + text_OUT); } //Interactively input a text-message to be encoded & sent // The message is recorded in :text_IN: private static void enterText() { } //Create a Hamming encoding of the message in :text_IN: // The Hamming Code-Words are recorded in :buffer: private static void encodeText() { } //Simulate sending the coded message from the :buffer: // Introduce random single-bit errors in randomly selected codes private static void sendText() { for (int i = 0; i < buffer.size(); i++) { int[] bits = buffer.get(i); int index = (new Random()).nextInt(bits.length * 2); if ( index < bits.length ) { bits[index] = 1 - bits[index]; buffer.set(i, bits); } } } //Interpret the Hamming-encoded text stored in :buffer: // Detect & Correct any single-bit errors in each code // Store the interpreted message in :text_OUT: private static void decodeText() { } }