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

Practical examples of conditional statements

From the course: Programming for Non-Programmers: Android & Kotlin

Start my 1-month free trial

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…

Contents