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 Methods and Constants

What now?

I've complited the first task by making a field, that should store the number of bars in a battery (8). Here's what I wrote:

public class GoKart {
  private String mColor;

  public static final int MAX_BARS = 8; //that was written for the 1. task

  public GoKart(String color) {
    mColor = color;
  }

  public String getColor() {
    return mColor;
  } 
}

But now, I'm stuck at the 2. task:

Now let's add a private uninitialized field to store the current number of energy bars. Name it mBarsCount. Initialize it to zero in the constructor.

I don't understand, what to do.

3 Answers

you are creating a member variable that will store the current number of bars in the GoKart. it should look something like this java <p> private int mBarsCount; <p/> The variable is declared but it is not defined. In its current state is simply a place to store input later. Inside the GoKarts constructor you will define mBarsCount as 0. In case you are wondering where the constructor is, it is the line of code just below where you have MAX_BARS defined. Make sure that you set the mBarsCount variable outside of the constructor. I hope this helps!

One more question. What does <p> and <p/> mean?

Ignore that lol I was trying to format my response apparently I still need to figure it out.

ok