+ 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

31st Jul 2017, 10:10 PM
X-1
X-1 - avatar
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.
1st Aug 2017, 1:27 AM
jay
jay - avatar
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 :)
31st Jul 2017, 11:39 PM
James Cooke