How do I solve this using Swift code? 8 of 10

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

How do I solve this using Swift code? 8 of 10

10
struct RunningWorkout {
11
var distance: Double
12
var time: Double
13
var elevation: Double
14
15
}
16
17
In other app exercises, you've provided encouraging messages to the user based on how many steps they've completed. A great place to check whether or not you should
display something to the user is in a property observer.
In the Steps struct below, add a willSet to the steps property that will check if the new value is equal to goal, and if it is, prints a congratulatory message. Create an
instance of Steps where steps is 9999 and goal is 10000, then call takeStep() and see if your message is printed to the console.
23
struct Steps {
24
var steps: Int
25
var goal: Int
26
27
mutating func takeStep() {
steps += 1
}
28
29
30
}
31
32
Previous | page 8 of 10 | Next: Exercise - Type Properties and Methods
Transcribed Image Text:10 struct RunningWorkout { 11 var distance: Double 12 var time: Double 13 var elevation: Double 14 15 } 16 17 In other app exercises, you've provided encouraging messages to the user based on how many steps they've completed. A great place to check whether or not you should display something to the user is in a property observer. In the Steps struct below, add a willSet to the steps property that will check if the new value is equal to goal, and if it is, prints a congratulatory message. Create an instance of Steps where steps is 9999 and goal is 10000, then call takeStep() and see if your message is printed to the console. 23 struct Steps { 24 var steps: Int 25 var goal: Int 26 27 mutating func takeStep() { steps += 1 } 28 29 30 } 31 32 Previous | page 8 of 10 | Next: Exercise - Type Properties and Methods
App Exercise - Mile Times and Congratulations
Note
These exercises reinforce Swift concepts in the context of a fitness tracking app.
The RunningWorkout struct below holds information about your users' running workouts. However, you decide to add information about average mile time. Add a
computed property called averageMileTime that uses distance and time to compute the user's average mile time. Assume that distance is in meters and 1600
meters is a mile.
Create an instance of RunningWorkout and print the averageMileTime property. Check that it works properly.
10
struct RunningWorkout {
11
var distance: Double
12
var time: Double
13
var elevation: Double
14
15
16
17
In other app exercises, you've provided encouraging messages to the user based on how many steps they've completed. A great place to check whether or not you should
display something to the user is in a property observer.
In the Steps struct below, add a willSet to the steps property that will check if the new value is equal to goal, and if it is, prints a congratulatory message. Create an
instance of Steps where steps is 9999 and goal is 10000, then call takeStep() and see if your message is printed to the console.
23
struct Steps {
var steps: Int
var goal: Int
24
25
26
27
mutating func takeStep() {
Transcribed Image Text:App Exercise - Mile Times and Congratulations Note These exercises reinforce Swift concepts in the context of a fitness tracking app. The RunningWorkout struct below holds information about your users' running workouts. However, you decide to add information about average mile time. Add a computed property called averageMileTime that uses distance and time to compute the user's average mile time. Assume that distance is in meters and 1600 meters is a mile. Create an instance of RunningWorkout and print the averageMileTime property. Check that it works properly. 10 struct RunningWorkout { 11 var distance: Double 12 var time: Double 13 var elevation: Double 14 15 16 17 In other app exercises, you've provided encouraging messages to the user based on how many steps they've completed. A great place to check whether or not you should display something to the user is in a property observer. In the Steps struct below, add a willSet to the steps property that will check if the new value is equal to goal, and if it is, prints a congratulatory message. Create an instance of Steps where steps is 9999 and goal is 10000, then call takeStep() and see if your message is printed to the console. 23 struct Steps { var steps: Int var goal: Int 24 25 26 27 mutating func takeStep() {
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY