All Downloads are FREE. Search and download functionalities are using the official Maven repository.

model.util.ConvertToValidCode Maven / Gradle / Ivy

There is a newer version: 2.3.3
Show newest version
package model.util;

/**
 * @author Quinn Liu ([email protected])
 * @version June 29, 2014
 */
public class ConvertToValidCode {
    /**
     * @param int2DArray must contain \n to represent the next line
     */
    public void printsToConsoleConvertedJavaForInt2DArray(String int2DArray) {
        System.out.println("\n= new int[][] {");
        System.out.print("{ ");
        int int2DArrayLength = int2DArray.length();
        for (int i = 0; i < int2DArrayLength; i++) {
            char currentChar = int2DArray.charAt(i);
            char nextChar = int2DArray.charAt(i + 1);

            if (nextChar == 'E') {
                System.out.print(currentChar);
                System.out.print(" }\n};");
                return;
            } else if (nextChar == '\n') {
                System.out.print(currentChar);
                System.out.print(" },\n{ ");
            } else {
                // skip \n char
                if (currentChar != '\n') {
                    System.out.print(currentChar + ",");
                }
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy