## Draw a Flag with Three Colors - Intro to Java Programming

• 0:00 - 0:06
Here is the French flag with three colors blue, white, and red. So, here it
• 0:06 - 0:10
looks like we have to make three decisions. Are we in the first third, the
• 0:10 - 0:14
middle third, or the last one? In java you would start out with the first
• 0:14 - 0:19
condition, and I'll leave it to you to fill in the details in the exercise.
• 0:19 - 0:23
Then, for the next part, you'll use an else if clause, so you simply write else
• 0:23 - 0:29
if followed by another condition. And finally, you use an else for the
• 0:29 - 0:35
remaining possibility. So, here you need to supply two conditions, is the point
• 0:35 - 0:39
in the left, is it in the middle or otherwise, of course, it has to be in the
• 0:39 - 0:46
rightmost part. This construction with if, else if. You can have other answers
• 0:46 - 0:51
if you'd like. And then, finally is a else. This is what you do anytime you get
• 0:51 - 0:55
multiple decisions. And I get worked down from the top to the bottom as you
• 0:55 - 0:59
would expect. The first condition gets checked if it's fulfilled the statement
• 0:59 - 1:04
is executed in here, and everything else is skipped. On the other hand, if the
• 1:04 - 1:07
first condition wasn't true, one would move to check the second condition and
• 1:07 - 1:13
if that one was true, it would be executed. If it wasn't, then the third one
• 1:13 - 1:17
would be executed. In other words, exactly one of these three blocks is
• 1:17 - 1:24
executed, depending on which condition is true or whether none of them is true.
• 1:24 - 1:28
Well, now it's your turn to try that with the French flag. Again, you'll be
• 1:28 - 1:34
given a point x y that could fall anywhere within the flag. And you need to
• 1:34 - 1:41
make a decision whether to return blue, white, or red. And when you do that be
• 1:41 - 1:45
sure to use an if, else if, else construction.
Title:
Draw a Flag with Three Colors - Intro to Java Programming
Description:

more » « less
Video Language:
English
Team:
Udacity
Project:
cs046: Intro to Programming
Duration:
01:46
 Udacity Robot edited English subtitles for 08-12 Draw a Flag with Three Colors Udacity Robot edited English subtitles for 08-12 Draw a Flag with Three Colors Udacity Robot edited English subtitles for 08-12 Draw a Flag with Three Colors Cogi-Admin edited English subtitles for 08-12 Draw a Flag with Three Colors Cogi-Admin added a translation

# English subtitles

## Revisions Compare revisions

• API
Udacity Robot
• API
Udacity Robot
• API
Udacity Robot