From the course: Programming for Non-Programmers: Android & Kotlin
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Practical examples of conditional statements
From the course: Programming for Non-Programmers: Android & Kotlin
Practical examples of conditional statements
- [Instructor] Now that we've covered all of the programming building blocks, let's take a review of this version of the calculator application, to look at how control flow elements, like loops, conditional statements, and when statements, are used in a real world app. Note that this is a version of a calculator application, not exactly line for line what we're going to write at the end of the course. It may be a little bit different than what you see here, but for the most part, everything is going to be pretty similar. So I'm scrolling down a little bit from the top into the setup calculator method. In here, you'll see an array of buttons created. There are all ten buttons in there. And then, there's a loop that's setting the on click listener for all of those buttons, using the array index. Inside of did press equals, there's an if statement that checks to see a boolean value. There's a when statement in here that checks to see the current mode of the calculator, and does different…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Conditional statements3m 20s
-
(Locked)
Using conditional statements5m 11s
-
(Locked)
Boolean values6m 24s
-
(Locked)
Arrays1m 45s
-
(Locked)
Using arrays3m 4s
-
(Locked)
Loops3m 42s
-
(Locked)
Using loops4m 25s
-
(Locked)
When statements2m 29s
-
(Locked)
Using when statements8m 6s
-
(Locked)
Practical examples of conditional statements2m 35s
-
(Locked)
Challenge: Build a mini calculator app2m 19s
-
(Locked)
Solution: Build a mini calculator app3m 3s
-
-
-
-