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 trialDisha Mohta
2,248 Pointshow do I fix the error?
I'm not sure how to do this challenge
class Car: Vehicle {
var numberOfSeats: Int
init(withDoors doors: Int, andWheels wheels: Int, andSeats seats: Int){
self.numberOfSeats = seats
super.init(withDoors: doors, andWheels: wheels)
}
}
let someCar = Car(withDoors: 4, andWheels: 4, andSeats: 4)
1 Answer
Jorge Solana
6,064 PointsHere's your problem:
Your task is to create a subclass of Vehicle, named Car, that adds an additional stored property numberOfSeats of type Int with a default value of 4.
In your code you're not initializing numberOfSeats to 4. Also, since a car normally have 4 wheels, I don't think you need to write any init code in the subclass and you can use the fathers instead just with the 2 parameters.
If you still encounter problems, we will stick around.