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

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Make the Clear button clear all values

Make the Clear button clear all values

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

Start my 1-month free trial

Make the Clear button clear all values

- [Instructor] The next step is to add the functionality to the Clear button. The Clear button is perhaps the easiest part of the calculator, because all we're doing is resetting the calculator to its default state. To do that, just scroll up and find all of our properties. These are the values that we want to change all of these properties to in the Did Press Clear method. We want to set Last Button Was mode to false, current mode to none, et cetera. The easiest way to do that is to highlight all of this code and select it, press Command or Control C to copy it, and then paste it inside of Did Press Clear. As we talked about earlier in the course, when we're changing the values of variables or properties, we never use the var keyword. Var is for creating a new variable. Since these properties already exist, we remove var and a space, and just change their values here. Let's do that for all four of these. Delete var and a space. Now we reset the properties to their default values. The…

Contents