Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Sam Kearney
2,058 PointsClass Inheritance Code Challenge Help
I think the initialiser is what's throwing it off, but I'm not sure what's wrong. Anyone see the issue?
Thanks
class Vehicle {
var numberOfDoors: Int
var numberOfWheels: Int
init(withDoors doors: Int, andWheels wheels: Int) {
self.numberOfDoors = doors
self.numberOfWheels = wheels
}
}
// Enter your code below
class Car: Vehicle {
let numberOfSeats: Int = 4
init(withSeats seats: Int) {
self.numberOfSeats = seats
}
}
let someCar = Car(withSeats: 5)
1 Answer

Dylan Glover
2,525 PointsHey Sam, Got this answer from an older question on this challenge, but it passes and seems to explain pretty well. Looks like you were really close!
class Vehicle {
var numberOfDoors: Int
var numberOfWheels: Int
init(withDoors doors: Int, andWheels wheels: Int) {
self.numberOfDoors = doors
self.numberOfWheels = wheels
}
}
// Enter your code below
class Car: Vehicle {
var numberOfSeats: Int = 4
init(numbersOfSeats: Int) {
// We first give values to "numberOfSeats
self.numberOfSeats = numbersOfSeats
// Then we call super init
super.init(withDoors: 2, andWheels: 4)
}
}
let someCar = Car(numbersOfSeats: 2)
Hope this helps!
Dylan
Sam Kearney
2,058 PointsSam Kearney
2,058 PointsI understand it much better now. Thank you!
Dan K
10,640 PointsDan K
10,640 Pointswhy don't you add "doors" and "wheels" when you call super init?