package Model;

public class RandomTextCreator {

    //1. dfjk
    //2. asl;
    //3. asdf jkl;
    //4. ei
    //5. gh
    //6. c,
    //7. asdfg hjkl; ei gh c,
    //8. ASDFG HJKL: EI GH C<
    //9. asdfg hjkl; ei gh c, ASDFG HJKL: EI GH C<
    //10. ru
    //11. vm
    //12. ty
    //13. ru vm ty
    //14. RU VM TY
    //15. ru vm ty RU VM TY
    //16. bn
    //17. wo
    //18. x./
    //19. bn wo x./
    //20. BN WO X>?
    //21. bn wo x./ BN WO X>?
    //22. qp
    //23. z\'
    //24. \[]
    //25. {}
    //26. qp z\' \[] {}
    //27. QP Z|" -= _+
    //28. qp z\' \[] {} QP Z|" -= _+

    /**
     * dfjk
     * 100 102 106 107
     * @param iTextLength
     * @return
     */
    public static String lesson1(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {100, 102, 106, 107};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }
    
    /**
     * asl;
     * 97 115 108 59
     * @param iTextLength
     * @return
     */
    public static String lesson2(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {97, 115, 108, 59};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * asdf jkl;
     * 97 115 100 102 106 107 108 59
     * @param iTextLength
     * @return
     */
    public static String lesson3(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {97, 115, 100, 102, 106, 107, 108, 59};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * ei
     * 101 105
     * @param iTextLength
     * @return
     */
    public static String lesson4(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {101, 105};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * gh
     * 103 104
     * @param iTextLength
     * @return
     */
    public static String lesson5(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {103, 104};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * c,
     * 99 44
     * @param iTextLength
     * @return
     */
    public static String lesson6(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {99, 44};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * asdf jkl; ei gh c,
     * 97 115 100 102 106 107 108 59 101 105 103 104 99 44
     * @param iTextLength
     * @return
     */
    public static String lesson7(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {97, 115, 100, 102, 106, 107, 108, 59, 101, 105, 103, 104, 99, 44};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * ASDF JKL: EI GH C<
     * 65 83 68 70 74 75 76 58 69 73 71 72 67 60
     * @param iTextLength
     * @return
     */
    public static String lesson8(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {65, 83, 68, 70, 74, 75, 76, 58, 69, 73, 71, 72, 67, 60};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * asdf jkl; ei gh c, ASDF JKL: EI GH C<
     * 97 115 100 102 106 107 108 59 101 105 103 104 99 44 65 83 68 70 74 75 76 58 69 73 71 72 67 60
     * @param iTextLength
     * @return
     */
    public static String lesson9(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {97, 115, 100, 102, 106, 107, 108, 59, 101, 105, 103, 104, 99, 44, 65, 83, 68, 70, 74, 75, 76, 58, 69, 73, 71, 72, 67, 60};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * ru
     * 114 117
     * @param iTextLength
     * @return
     */
    public static String lesson10(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {114, 117};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * vm
     * 118 109
     * @param iTextLength
     * @return
     */
    public static String lesson11(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {118, 109};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * ty
     * 116 121
     * @param iTextLength
     * @return
     */
    public static String lesson12(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {116, 121};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * ru vm ty
     * 114 117 118 109 116 121
     * @param iTextLength
     * @return
     */
    public static String lesson13(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {114, 117, 118, 109, 116, 121};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * RU VM TY
     * 82 85 86 77 84 89
     * @param iTextLength
     * @return
     */
    public static String lesson14(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {82, 85, 86, 77, 84, 89};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * ru vm ty RU VM TY
     * 114 117 118 109 116 121 82 85 86 77 84 89
     * @param iTextLength
     * @return
     */
    public static String lesson15(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {114, 117, 118, 109, 116, 121, 82, 85, 86, 77, 84, 89};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * bn
     * 98 110
     * @param iTextLength
     * @return
     */
    public static String lesson16(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {98, 110};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * wo
     * 119 111
     * @param iTextLength
     * @return
     */
    public static String lesson17(int iTextLength) {
        String sReturn = "";
        int[] aiLetters = {119, 111};
        for (int i = 0; i < iTextLength; i++) {
            int iOption = randomNumber(0, aiLetters.length - 1);
            sReturn += String.valueOf(Character.toChars(aiLetters[iOption]));
        }
        return sReturn;
    }

    /**
     * Creates random Text with
     * @param iTextLength
     */
    public static String createText(int iTextLength) {
        String sReturn = "";
        int iLastOption = 0;

        for (int i = 0; i < iTextLength; i++) {
            int iMin = 0;
            int iMax = 3;
            if (i % 2 == 0) {
                iMin = 1;
                iMax = 2;
            }

            int iOption = randomNumber(iMin, iMax);
            while (iOption == iLastOption) {
                iOption = randomNumber(iMin, iMax);
            }

            switch (iOption) {
                //48-57 0-9
                case (0): {
                    sReturn += createText0();
                }break;
                //65-90 A-Z
                case (1): {
                    sReturn += createText1();
                }break;
                //97-122 a-z
                case (2): {
                    sReturn += createText2();
                }break;
                //?!()=+,-[]{}
                case (3): {
                    sReturn += createText3();
                }break;
            }     

            iLastOption = iOption;
        }

        return sReturn;
    }

    //48-57 0-9
    private static String createText0() {
        int iOption = randomNumber(48, 57);
        return String.valueOf(Character.toChars(iOption));
    }

    //65-90 A-Z
    private static String createText1() {
        int iOption = randomNumber(65, 90);
        return String.valueOf(Character.toChars(iOption));
    }

    //97-122 a-z
    private static String createText2() {
        int iOption = randomNumber(97, 122);
        return String.valueOf(Character.toChars(iOption));
    }

    //?!()=+,-[]{}
    //63 33 40 41 61 43 44 45 91 93 123 125 
    private static String createText3() {
        int [] aiOptions = {63, 33, 40, 41, 61, 43, 44, 45, 91, 93, 123, 125};
        int iOption = randomNumber(0, 11);
        return String.valueOf(Character.toChars(aiOptions[iOption]));
    }

    /**
     * Creates random Number in range of iMin and iMax
     * @param iMin
     * @param iMax
     * @return
     */
    private static int randomNumber(int iMin, int iMax) {
        return (int)(Math.random() * (iMax - iMin + 1) + iMin);
    }
}