English subtitles

← And Or Not - Intro to Java Programming

Get Embed Code
5 Languages

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

  1. Here's how I solve this problem. There are four different conditions. All four
  2. had to be true. So I join them with the and operator. So let's start with the
  3. x-axis. x has to be at least width over 3, and it should be at most twice that.
  4. The y value should be at least height over 3, and it should be at most twice
  5. that. So, here are my four conditions joined by and. When all of them are true,
  6. then the pixel should be blue, otherwise it should be white. Now, you may be
  7. wondering, what's the deal with the greater equals versus less thans,
  8. particularly, if you didn't do it just so and your answer wasn't counted
  9. correctly. This is easiest to see with a specific example. So let's say we have
  10. 300 by 300 flag. That means that the x and y positions range from 0 to 299. We
  11. want each of these three areas to have equal size, so the first one goes from 0
  12. to 99, the next one from 100 to 199, and the last one from 200 to 299. So to be
  13. within the second, of these, you want to be greater equal 100 and less than
  14. 200. That's why you have a greater equal here and a less than there. I know it
  15. seems like a fine point, but it is worth paying attention to. And here is what
  16. it looks like, when I run it.