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!

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 Harnessing the Power of Objects Computed Properties

Kade Carlson
Kade Carlson
5,928 Points

Not sure what task 2 is asking of me

What should I do here?

class GoKart {
  public static final int MAX_BARS = 8;
  private String color;
  private int barCount;

  public GoKart(String color) {
    this.color = color;

  public String getColor() {
    return color;

  public void charge() {
    barCount = MAX_BARS;

  public boolean isBatteryEmpty() {
    if (barCount == 0) {
      return true;
    } else {
      return false;

    public boolean isFullyCharged() {
      if (!isBatteryEmpty()) {
        System.out.println("Battery is fully charged");

1 Answer

Bryanna Obrien
Bryanna Obrien
Courses Plus Student 4,700 Points

In the first challenge, you had to create the method that checked to see if the battery was empty by checking to see if the barCount was equal to 0. The second challenge is very similar, except this time we're checking to see if the battery has the maximum barCount allowed. So, instead of testing if (barCount == 0), you would want to test if (barCount == MAX_BARS).

The way you had your method just checks that the battery is not empty, but not empty could mean anything from 1 bar to 8 bars.