A simple way of encoding a message is the railfence cypher. The message is written downwards and diagonally on rails of an imaginary fence, moving down and up. The message, Howareyou? becomes

H . . . r . . . u .
. o . a . e . o . ? 
. . w . . . y . . .
which is then encoded as Hruoaeo?wy

Write a method that receives a string and that returns a two-dimensional array of strings, placing the characters as indicated in the preceding diagram. Each array element should either be null (represented by . above) or a string of length 1.

Complete the following file:

Railfence.java

import java.util.ArrayList; /** Encodes strings using the Railfence cipher. */ public class Railfence { /** Arranges a message in a fence pattern @param message any string @return a two-dimensional array of strings that are either null (.) or strings of length 1, arranged in a pattern like this m . . . a . . . e . s . g . . . s . . . e */ public String[][] makeFence(String message) { // your work here } // This message is used to check your work public String encode(String message) { String[][] fence = makeFence(message); String result = ""; for (int i = 0; i < fence.length; i++) for (int j = 0; j < fence[i].length; j++) if (fence[i][j] != null && fence[i][j].length() == 1) result = result + fence[i][j]; return result; } }