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!
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 trial

mathisvaneetvelde
9,366 PointsClasses and their methods
Hello, i'm stuck on this challenge. Can someone help me ?
This is what i have to do: 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).
My error is that my code could not be compiled. But when i preview my code it sais nothing
class Button {
var width: Double
var height: Double
var points: Double
init(width:Double, height:Double, points:Double){
self.width = width
self.height = height
self.points = points
}
func incrementBy(points: Double) {
}
}
1 Answer

Alvin Abia
Courses Plus Student 23,034 PointsHey Mathis, in order to increment the button's width and height by the value passed in the points parameter you would add these two lines:
func incrementBy(points: Double) {
width += points
height += points
}
Hope this helps!
mathisvaneetvelde
9,366 Pointsmathisvaneetvelde
9,366 PointsThanks a lot, it worked!
David Maybach
2,092 PointsDavid Maybach
2,092 Pointswhy not include return so ....return.width += points and so forth for height?