Programming in Swift: Functions & Types

Jan 4 2022 Swift 5.5, iOS 15, Xcode 13

Part 4: Properties & Methods

34. Challenge: Methods

Lesson Complete

Play Next Lesson
Next
Save for later
About this episode
See versions

See course reviews

See forum comments
Cinema mode Mark as Complete Download course materials
Previous episode: 33. Methods Next episode: 35. Computed Properties or Methods?

Update Notes: This course was originally recorded in 2019. It has been reviewed and all content and materials updated as of October 2021.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.

It’s time for some practice with methods. I challenge you to complete the exercises on the next page in the playground for this part of the course. Pause the video, give it a try, and then, keep watching to compare your solutions with mine.

  mutating func curveGrades() {

  }
41 var grade…
46 var students
53 var classroom
guard let highestGrade = getHighestGrade() else {
      return
    }
students =
      students.map { student in
        return student
      }
75 let curveAmount = 100 - highestGrade
76 var student = student
77 student.grade += curveAmount
74 students.map { [curveAmount = 100 - highestGrade] student in
        var student = student
79 .sorted { $0.grade > $1.grade }
classroom.curveGrades()
84 classroom.students