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

Amen Machewu
Amen Machewu
606 Points

Study Files Code

Where do we save and find the code that we will be writing throughout the course? I see there is a note that says the current code should be added to the previous code; how do we do that?

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

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

  //create a method that returns true if battery percentage is 0 
  public boolean isBatteryEmpty(){
      return barCount == 0;
  }

  //create a method that returns true if the battery is fully charged
  public boolean isFullyCharged(){
      return barCount ==8;
  }

  public String getColor() {
    return color;
  }

  public void charge() {
    barCount = MAX_BARS;
  }
}

1 Answer

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

Hey there!

Are you referring to this notice above the code in the challenge?

In each task of this code challenge, the code you write should be added to the code from the previous task.

This just means that as you progress through the steps in this individual challenge, you'll build off of the code you wrote in the last step. So no worries on step 1, when you get to step 2, it just means build off of what you've done in the 1st. You're good to go 👍