Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Relational Operators - Intro to Java Programming

Get Embed Code
6 Languages

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

  1. Here's how I figured it out. If I look at an arbitrary point, x and y, where as
  2. always in our graphical coordinate systems, x grows this way and y grows this
  3. way, downward. And it's clear that the x value here has nothing to do with
  4. which color to chose. But the y value does, so I have to worry about the y
  5. value being. Greater than or maybe greater equal, we'll come back to that in a
  6. minute, then half the height. Now if it's greater than or greater than equal,
  7. or less than or less than equal, it's easy if it would make these things wrong.
  8. So, let's look at the actual numbers. Let's assume that the height is 200. In
  9. that case the Y values can be from 0 to 199. So, if they're from 0 to 99 then I
  10. want red. And if they're from 100 to 199 then I want white. So, if height is
  11. 200 then height is over 2 is 100. Greater or equal than 100 should give me
  12. wide. So, this is exactly the right condition, we'll put it in here and
  13. otherwise I want Red. Let me put it in and demo it to you. I'll just make a
  14. flag, many flags as I want in a half times as wide as they are tall and I'll
  15. use the same here. And here it is. Red on top, white on the bottom. Let's move
  16. on to a more complicated flag.