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 trialEdgard Silva
2,711 PointsDon't get the point of the question
We need to provide a means to increase the size of our Button. So we are going to add a method named incrementBy which will accept a parameter named points. (Within the method add points to the width and height properties).
What do they mean by add points to width and height properties?
Here's what i have so far, i don't know where to go from there...
class Button {
var width: Double
var height: Double
init(width:Double, height:Double)
{
self.width = width
self.height = height
}
func incremenetBy(points : Double) -> Double
{
}
3 Answers
Chris Shaw
26,676 PointsHi Edgard,
This challenge is slightly confusing in regards to it's terminology but it's simply asking for you to add the value of points to the height
and width
properties for the Button
class which we can do two ways, before however I want to mention you also spelled increment wrong, you have an extra e in there that can be dropped.
First way
func incrementBy(points: Double) {
self.height += points
self.width += points
}
Second way
func incrementBy(points: Double) {
self.height = self.height + points
self.width = self.width + points
}
Hope that helps.
Sean Turner
1,415 PointsI had a hard time understanding what the question was asking as well. Thanks for clarifying, Chris.
Reid Burnett
2,856 PointsYes, very very confusing question. Thank you Chris Upjohn