+ 1
I need help fixing my method
my method used cars as objects, and allows you to change the colour and add a spoiler. I've created a method that allows you to choose what you want to do to the car, passing in parameters as appropriate, but the method fails to be called. could someone help? https://code.sololearn.com/c4NRq5yoPkPr/?ref=app
2 odpowiedzi
+ 8
in edit_car() you pass the car object.. this is not required as it is the class is already the object.
also in the same method. option is always empty. it never gets input.
0
Rather than returning void, try returning an int, and then in the main method do e.g. If 1 then lambo.add_spoiler() else if 2 then lambo.change_colour()
Don't pass any parameters as you won't need any
I'm aware this is a workaround rather than a fix on ur code.
Personally I'd do the decisions in the main method and then call the appropriate class method. It doesn't make sense to me why the decision would be coupled with the object. If someone could explain why that would be great :)