Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGa-eun Kim
2,558 PointsI don't understand the question
What is the method supposed to do, and what should my code look like?
Dominic Pettifer
4,338 PointsJhoan, the question is referring to one of the exercises in the Object-oriented Swift course, there's a link to the exercise on the right of this page, under Related Content heading. The Treehouse UI doesn't make this very clear.
1 Answer
Dominic Pettifer
4,338 PointsI don't want to just put the answer here, you learn faster if you can figure it out yourself. But start with something like the following function:
func incrementBy(points: Double) {
// increment width and height here
}
So, we're passing in a points parameter of type Double and adding that to the width and height stored properties. How do you think we can add points to width and height in the function? Here's a clue:
self.width = self.width + ????
...what should ???? be? Also do the same for height.
Ga-eun Kim
2,558 PointsThanks a lot! The 2nd part of the question was a bit confusing, but your answer clarified it :)
Jhoan Arango
14,575 PointsJhoan Arango
14,575 PointsHi, Try showing us your code and or the question.