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 trialCed I
999 PointsQuestion wording confusion
In the last sentence of this problem, it says: "Once you've implemented the Car class, create an instance and assign it to a constant named someCar." But in order create an instance of this new class, we need to pass in the parameters that it requires but the prompt doesn't give us any values to pass in. Do you want us to just pass in any values we feel like? Or is there a way to create an instance of a class without passing in any parameters that I missed? 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 {
var numberOfSeats: Int = 4
}
let someCar = Car()
1 Answer
Steve Hunter
57,712 PointsHi there,
Just pass in some values that you create:
// Enter your code below
class Car: Vehicle {
var numberOfSeats: Int = 4
}
let someCar = Car(withDoors: 4, andWheels: 4)
That works fine!
Steve.
Ced I
999 PointsCed I
999 PointsThanks Steve! I don't know if you control this but the prompt should be more explicit about letting us put in any parameters we like when creating a new instance. Or they should just give us some values to put in. Just a suggestion!
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsHi Ced,
Thanks for the input. I don't control that side of things at all, I must say.
It's really difficult to balance every student's different learning styles and needs. Some like to be walked through each aspect; I tend in that direction. Others want less leading and need to learn by experimentation. Both work for different people at different times.
I'd suggest trying to complete the challenge and if you run into problems, shout on the Community pages. Someone will help. If you get no response you can always @ mention me; I'll reply as quickly as I am able.
Steve.