In this lecture, we are going to see some examples to control flow first, create a class for this
to so write like new class.
Control follow up and to copy a main method from one of the fires we have created before.
Copy and paste it here, and we're going to need three variables a boolean is damaged, is damaged.
That will be through
a string car color.
Equals purple.
And they charged energy efficiency category.
He calls simple chords G and a semicolon, our first example is using is damaged, so F parentheses
is damaged, curly braces and a system that our daughter Winterland double chords, damaged car now
in our code.
As you can see, damaged car is printed out.
OK, let's change is damage to force.
Now, run called again, as you can see, nothing is printed out now add an ounce to it.
So here else, curly braces copied this line pasted here.
Now change the text.
When I called.
As you can see, accident free car is printed out, so now instead of printing out, nothing is damaged
is force accident free car is printed out.
Let's move on to our stuff now.
So F.
Car color dot equals red curly braces.
System dot out of print and double quotes.
This car is red now at an Alice F.
Else F Frantz's car color, that equals double quotes, green, curly braces system not out of print
one copy the text.
And change the red to green.
Now add another one as well as it's car color, dot equals blue.
Call it racist cop D-line and change green to blue, our honor code.
And as you can see, nothing else is printed out, an accident free car.
It's pretty obvious because we don't have any condition for purple.
So instead of adding a house, if Corker equals purple, we add an ass here.
Curly braces.
Copied this line and changed the text to.
I have no idea what's the color of the car or on the road again.
And as you can see, the newly added code that belongs to Alse is executed.
Now, let's see an example for which we are going to use energy efficiency category here, so switch
energy efficiency category curly braces and let's just say we are lazy and we want to print out the
same text for both A and B category.
So case simple quote a column.
Case.
Simple codes, chords be.
Colin into system that outthought Winterland double cotes.
Low energy consumption.
New line and brake words and a semicolon.
Now let's add another case.
G Colin system thought out that print on copy the text.
Posted here and changed the tax to very high energy consumption and new line.
A break and a semicolon now run out of code.
OK, so as we expected, very high energy consumption is printed out because we have a case here.
Now let's change the value of an energy efficiency category to a.
Right now called again, and as you can see, low energy consumption is printed out now, change it
to be run it again.
So what's happened here in case of A and B?
The same code is printed out now, change the value to Z, run our code again, nothing is printed out
now.
So our last move here is to add a Difford block to the switch.
So enter default column and enter again system dot, dot printer and double codes, not defined category
runner code again.
So as you can see, because we change the value to see the not defined category text is printed out
in the default block.
All right.
That's it about contraflow.
I hope it was clear and useful.
If it was not, feel free to ask C in the next lecture.