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
Jean-Pierre Mudiasa
4,552 PointsMy code is ok in Xcode but the editor cannot compile :(
class Vehicle { var numberOfDoors: Int var numberOfWheels: Int
init(withDoors doors: Int, andWheels wheels: Int) {
self.numberOfDoors = doors
self.numberOfWheels = wheels
}
}
class car: Vehicle {
let numberOfSeats: Int = 4
override init(withDoors doors: Int, andWheels wheels: Int) {
super.init(withDoors: doors, andWheels: wheels)
}
}
let someCar = car(withDoors: 5, andWheels: 4)
2 Answers
David Papandrew
8,386 PointsTry changing the "car" class to uppercase "Car". Make sure you update the capitalization for the someCar instance too.
I tried this and the code passed. The challenge tool seems to be case sensitive (that and general practice for Swift is to use initial capital letter for class names).
class Vehicle {
var numberOfDoors: Int
var numberOfWheels: Int
init(withDoors doors: Int, andWheels wheels: Int) {
self.numberOfDoors = doors
self.numberOfWheels = wheels
}
}
class Car: Vehicle {
let numberOfSeats: Int = 4
override init(withDoors doors: Int, andWheels wheels: Int) {
super.init(withDoors: doors, andWheels: wheels)
}
}
let someCar = Car(withDoors: 5, andWheels: 4)
Jean-Pierre Mudiasa
4,552 PointsHello David,
Thx so much for your help.. the mistake was having a class name with a lowercase.. It worked just fine when I changed the class name to Car.