@@ -0,0 +1,2658 @@
+public class RouteCipher%0A%7B%0A    /** A two-dimensional array of single-character strings, instantiated in the constructor */%0A    private String%5B%5D%5B%5D letterBlock;%0A%0A    /** The number of rows of letterBlock, set by the constructor */%0A    private int numRows;%0A%0A    /** The number of columns of letterBlock, set by the constructor */%0A    private int numCols;%0A%0A    /** Places a string into letterBlock in row-major order.%0A     * @param str the string to be processed%0A     * Postcondition:%0A     * if str.length() %3C numRows * numCols, %22A%22 is placed in each unfilled cell%0A     * if str.length() %3E numRows * numCols, trailing characters are ignored%0A     */%0A    private void fillBlock(String str) %7B%0A        while (str.length() %3C numRows * numCols)%0A            str += 'A';%0A%0A        int strIndex = 0;%0A%0A        for (int row = 0; row %3C letterBlock.length; row++) %7B%0A            for (int col = 0; col %3C letterBlock%5B0%5D.length; col++) %7B%0A                letterBlock%5Brow%5D%5Bcol%5D = str.substring(strIndex, strIndex + 1);%0A                strIndex++;%0A            %7D%0A        %7D%0A        printLetterBlock();%0A    %7D%0A%0A    /** Extracts encrypted string from letterBlock in column-major order.%0A     * Precondition: letterBlock has been filled%0A     * @return the encrypted string from letterBlock%0A     */%0A    private String encryptBlock()%0A    %7B%0A        String out = %22%22;%0A        for (int col = 0; col %3C letterBlock%5B0%5D.length; col++)%0A            for (int row = 0; row %3C letterBlock.length; row++)%0A                out += letterBlock%5Brow%5D%5Bcol%5D;%0A        return out;%0A    %7D%0A%0A    /** Encrypts a message.%0A     * @param message the string to be encrypted%0A     * @return the encrypted message;%0A     * if message is the empty string, returns the empty string%0A     */%0A    public String encryptMessage(String message)%0A    %7B%0A        if (message.equals(%22%22)) return %22%22;%0A%0A        String out = %22%22;%0A        for (int i = 0; i %3C message.length(); i += numRows * numCols) %7B%0A            fillBlock(message.substring(i, Math.min(i + numRows * numCols, message.length())));%0A            out += encryptBlock();%0A        %7D%0A        return out;%0A    %7D%0A%0A    public void printLetterBlock() %7B%0A        for (int row = 0; row %3C letterBlock.length; row++) %7B%0A            for(int col = 0; col %3C letterBlock%5B0%5D.length; col++) %7B%0A                System.out.print(letterBlock%5Brow%5D%5Bcol%5D + %22%5Ct%22);%0A            %7D%0A            System.out.println(%22%22);%0A        %7D%0A    %7D%0A%0A    public static void main (String%5B%5D args)%0A    %7B%0A        RouteCipher c = new RouteCipher();%0A        c.numRows = 2;%0A        c.numCols = 3;%0A        c.letterBlock = new String%5Bc.numRows%5D%5Bc.numCols%5D;%0A        System.out.println(%22%5B%22 + c.encryptMessage(%22Meet at midnight%22) +%22%5D%22);%0A    %7D%0A%7D%0A

Add RouteCipher.java