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 trial
Philip Huffman
23,050 PointsTreehouse has issues with source that works in xCode
Hi All,
Treehouse will not compile the source code below in challenge task 3 of 3 in the "What is Inheritance" section.
If anyone can tell me how to get around this, I would be grateful.
Thanks,
PHIL
Here is the source code:
class Button { var width: Double var height: Double
init(width:Double, height:Double){ self.width = width self.height = height }
func incrementBy(points: Double){ width += points height += points }
}
class RoundButton: Button { var cornerRadius: Double
init(width: Double, height: Double, cornerRadius: Double ) { if cornerRadius > 0.0 { self.cornerRadius = cornerRadius } else { self.cornerRadius = 5.0 }
super.init(width: width, height: height)
}
override func incrementBy(_ points: Double = 7.0){ super.incrementBy(points) } }
var rounded: RoundButton
11 Answers
Caleb Kleveter
Treehouse Moderator 37,862 PointsI don't know what your issue is, but I think you should contact help@teamtreehouse.come.
Philip Huffman
23,050 PointsHere's the complete source. Sorry about miss the 3 back tics on the original.
class Button {
var width: Double
var height: Double
init(width:Double, height:Double){
self.width = width
self.height = height
}
func incrementBy(points: Double){
width += points
height += points
}
}
class RoundButton: Button {
var cornerRadius: Double
init(width: Double, height: Double, cornerRadius: Double ) {
if cornerRadius > 0.0 {
self.cornerRadius = cornerRadius
} else {
self.cornerRadius = 5.0
}
super.init(width: width, height: height)
}
override func incrementBy(_ points: Double = 7.0){
super.incrementBy(points)
}
}
var rounded: RoundButton
Caleb Kleveter
Treehouse Moderator 37,862 PointsWhat do you mean by it won't compile it? Are you getting a "cannot communicate" message?
Philip Huffman
23,050 PointsThank you, Caleb.
It won't successfully compile, and there are no error messages. The output screen only has an HTML tag.
No, there is no "cannot communicate" message.
Caleb Kleveter
Treehouse Moderator 37,862 PointsIs this in a code challenge?
BTW. I love your profile picture :).
Philip Huffman
23,050 PointsYes, it's a code challenge.
Caleb Kleveter
Treehouse Moderator 37,862 PointsDo you mean that your code is wrong but when you go preview there is no output?
Philip Huffman
23,050 PointsNot exactly. I believe my code is correct, and Treehouse will not accept it. Furthermore, no error message is provided.
Caleb Kleveter
Treehouse Moderator 37,862 PointsDo you get a bummer message or a correct message or something completely different?
Philip Huffman
23,050 PointsI get the bummer message.
Caleb Kleveter
Treehouse Moderator 37,862 PointsWhat does it say? I don't know Swift so I might not be of much help.
Philip Huffman
23,050 PointsBy "it" I assume you mean the bummer message. I just says that my code could not be compiled (yet it works in xCode), and to check the preview screen for the (nonexistent) error message.
Philip Huffman
23,050 PointsThank you Caleb.