// Allison Obourn
// CS& 141, Winter 2021
// Lecture 17

// Prints out whether some letters are vowels and tries to generate a lucky 7
// by generating 10 random numbers 1 - 30 twice. 

import java.util.*;

public class Examples {
   public static void main(String[] args) {
      System.out.println("isVowel(\"d\"): " + isVowel("d"));
      System.out.println("isVowel(\"e\"): " + isVowel("e"));
      System.out.println("isVowel(\"E\"): " + isVowel("E"));
      System.out.println("isVowel(\"N\"): " + isVowel("N"));
      
      System.out.println("isNonVowel(\"d\"): " + isNonVowel("d"));
      System.out.println("isNonVowel(\"e\"): " + isNonVowel("e"));
      System.out.println("isNonVowel(\"E\"): " + isNonVowel("E"));
      System.out.println("isNonVowel(\"N\"): " + isNonVowel("N"));
      
      Random rand = new Random();
      System.out.println("Call 1: " + seven(rand));
      System.out.println("Call 2: " + seven(rand));
   }

   // returns true if the passed in string is a vowel, false otherwise
   // assumes that the string is one character long
   public static boolean isVowel(String letter) {
      return letter.equalsIgnoreCase("a") || letter.equalsIgnoreCase("e") || letter.equalsIgnoreCase("i")
            || letter.equalsIgnoreCase("o") || letter.equalsIgnoreCase("u");
   }
   
   // returns true if the passed in string isn't a vowel, false otherwise
   // assumes that the string is one character long
   public static boolean isNonVowel(String letter) {
      // alternate solution:
      //return !letter.equalsIgnoreCase("a") && !letter.equalsIgnoreCase("e") && !letter.equalsIgnoreCase("i")
      //     && !letter.equalsIgnoreCase("o") && !letter.equalsIgnoreCase("u");
      return !isVowel(letter);
   }
  
  // takes a random generator as a parameter
  // prints out random numbers between 1 and 30 until either getting to 10 or printing a 7
  // returns true if it has printed 7, false otherwise
  public static boolean seven(Random rand) {
     for(int i = 0; i < 10; i++) {
        int number = rand.nextInt(30) + 1;
        System.out.print(number + " ");
        if(number == 7) {
           return true;
        } 
     }
     return false;
  }

}