English subtitles

← Using Booleans - Intro to Java Programming

Get Embed Code
6 Languages

Showing Revision 5 created 05/25/2016 by Udacity Robot.

  1. In is vowel, we want to return true if letters.substring equals a or e or i or
  2. o, so we add those comparisons using or. So, it would look like this. I had to
  3. type letters dot substring a whole bunch of times maybe I should have made that
  4. a variable. And then, every word I used letters.substring i to i plus 1, I
  5. could replace them with letter. That looks a lot better now for is consonant a
  6. letter is a consonant if its not a vowel. So, I can take a shortcut here and
  7. just return not is vowel for the given index. I don't need to tell it that it's
  8. an int. And I didn't actually initialize letter. If I want to test my method, I
  9. can make a new word. I'll fill it with sleep. And now, if I ask if the first
  10. letter is a vowel, I get that it's not because it's an s. If I ask if it's a
  11. consonant, I get true. I would probably want to test a couple more cases if I
  12. was going to ship this code to somebody. But, this looks like it's working for
  13. now.