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 trial

Java Java Objects (Retired) Harnessing the Power of Objects Method Signatures

Isheanesu Jindu
Isheanesu Jindu
1,644 Points

java objects - method signatures

Bummer! Remember that you should call the existing drive method and pass in the default parameter of 1. Otherwise you would have to rewrite all that (omitted) code.

my code is

public void drive () {
mBarsCount -= 1;
}

2 Answers

Hi there,

The clue is in the error.

Because in the drive(int laps) method there is a LOT of code that you don't see. That could be anything to do with type wear, fuel levels; lots of things we don't need to know about. So, you can't just do one thing, mBarsCount -= 1; in the new drive method.

You are asked to create an alternative drive method that takes no parameters and just drives one lap.

So use the existing method inside the new one.

  public void drive(){
    drive(1);
  }

That way, all the hidden code gets run and one lap gets completed.

Make sense?

Steve.

Daniel Marsh
Daniel Marsh
4,533 Points

Thank you, Steve Hunter i was very confused as well i had public void drive(){drive(laps)--;} not understanding that the code had so much hidden i understand much better now.

No problem, Daniel. Glad you got it fixed.

Steve.

Isheanesu Jindu
Isheanesu Jindu
1,644 Points

man you are life saver, thank you !

Hey, no problem! :-)

Steve.