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 Helper Methods

Sameer Saini
Sameer Saini
1,072 Points

challenge asks me to create a method isBatteryEmpty and execute in it whether the GoKart needs to be charged or not ?

Create a helper method that returns whether or not the GoKart needs to be charged. Make it public and name it isBatteryEmpty.

Do I have to include any statement like this "return _____;" in the isBatteryEmpty method. I meant do I have to return anything in this method ?

Thank you

public class GoKart {
  public static final int MAX_BARS = 8;
  private String mColor;
  private int mBarsCount;

  public GoKart(String color) {
    mColor = color;
    mBarsCount = 0;

 public isBatteryEmpty {  //I made this method which has errors

System.out.println("Does the GoKart needs to be charged or not")  

  public String getColor() {
    return mColor;

  public void charge() {
    mBarsCount = MAX_BARS;

1 Answer

Christopher Augg
Christopher Augg
21,223 Points

Hello Sameer,

All you need to do is determine if the battery is not charged by checking if mBarsCount id equal to MAX_BARS snd return a boolean of true or false. Therefore, make the return type of the method a boolean and just return mBarsCount == MAX_BARS;

Hope that helps.