Advertisement
Guest User

Kavinsan FindCat

a guest
Nov 4th, 2014
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.57 KB | None | 0 0
  1. import java.util.Random;
  2. /**
  3.  *
  4.  * @author kavinsan
  5.  *
  6.  */
  7. public class FindCat {
  8.     public static void main (String[] args)
  9.     {
  10.         createWord();
  11.     }
  12.     /**
  13.      * Creates the word cat
  14.      * @return word
  15.      */
  16.     public static String createWord ()
  17.     {
  18.         String vowel = "aeiou";
  19.         String consonant = "bcdfghjklmnpqrstvwxyz";
  20.         int k = 0;
  21.         String word;
  22.         String firstWord;
  23.         String secondWord;
  24.         String thirdWord;
  25.         while(true){
  26.             Random r = new Random();
  27.             k = r.nextInt(21) + 1;
  28.             int i = consonant.length() - k;
  29.             //System.out.println(consonant.charAt(i)); Activate to see if random letter work
  30.                 if (i == 1){
  31.                 k = 0;
  32.                 System.out.println(consonant.charAt(i));//Check if the correct letter is found
  33.                 firstWord = consonant.substring(i,i+1);
  34.                 break;
  35.                 }
  36.         }
  37.         while(true){
  38.             Random r = new Random();
  39.             k = r.nextInt(5) + 1;
  40.             int i = vowel.length() - k;
  41.             //System.out.println(vowel.charAt(i)); Activate to see if random letter work
  42.                 if (i == 0){
  43.                 System.out.println(vowel.charAt(i));//Check if the correct letter is found
  44.                 secondWord = vowel.substring(i,i+1);
  45.                 break;
  46.                 }
  47.         }
  48.         while(true){
  49.             Random r = new Random();
  50.             k = r.nextInt(21) + 1;
  51.             int i = consonant.length() - k;
  52.             //System.out.println(consonant.charAt(i)); Activate to see if random letter work
  53.                 if (i == 15){
  54.                 System.out.println(consonant.charAt(i));//Check if the correct letter is found
  55.                 thirdWord = consonant.substring(i,i+1);
  56.                 break;
  57.                 }
  58.         }
  59.         return word;
  60.         word = firstWord + secondWord + thirdWord;
  61.         System.out.println(word);
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement