From the course: Programming for Non-programmers: iOS 17 and Swift 5
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Challenge: Conditionals
From the course: Programming for Non-programmers: iOS 17 and Swift 5
Challenge: Conditionals
- [Narrator] And now for this chapter's challenge, let's review what we talked about so far. Conditionals manage control flow by using if/else statements to execute certain blocks of code and a single condition can have multiple expressions. We got a little bit of practice throughout the chapter writing these kinds of statements. And now for the challenge. But first, a little bit of background. When working with a calculator and you press some numeric buttons, let's say you push a 1 and then you push the plus button. The next thing that happens is that when you press another button, that that number is going to replace the 1. So remember, you have two sets of numbers that you're performing operations on when you're creating a calculator. The 1 that was entered in before hitting the multiplication, subtraction, or addition button, and the 1 that was pressed after. In order to add that functionality, we need to check to see if the last button was pressed was a mode button. In other…
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
-
-
-
-
-
-
-
(Locked)
Understanding conditional statements4m 21s
-
(Locked)
Using conditional statements and Booleans4m 50s
-
(Locked)
Handling the numeric button presses4m 45s
-
(Locked)
Optionals and If Let statements3m
-
(Locked)
Enums5m 4s
-
(Locked)
Challenge: Conditionals2m 49s
-
(Locked)
Solution: Conditionals1m 51s
-
(Locked)
-
-