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 Changing State

whats wrong?

whats wrong?

GoKart.java
class GoKart {
  public static final int MAX_BARS = 8;
  private String color;
  private  int barCount;
 private int charge=0;
  public GoKart(String color) {
    this.color = color;
  }

  public String getColor() {
    return color;
  }

  public void int Charge(){
  barCount=MAX_BARS;
  }




}
Hoessein Abd
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Hoessein Abd
Python Web Development Techdegree Graduate 19,107 Points

When you say void it means the method can't return anything. So get rid of "int" otherwise you're saying don't return anything but return an int. Also remember the first word of your object needs to be lowercased:

public void charge() {
  barCount=MAX_BARS;
}

The instructions is asking you to only set the barCount to the maximum bars. So get rid of this line:

private int charge=0;

that should pass it.

1 Answer

Hey Charlie,

You are getting an error due to you adding in int in your method. You're not returning anything so it should be void.

You seems to have put both into your method.

Hope this helped.