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

Cole Turner
Cole Turner
5,872 Points

how do you add a method

How do I add a method called console? for some reason I get a complier issue that onl points to a right bracket.

GoKart.java
public class GoKart {
private String mColor;
public static final int MAX_BATTERY = 8;
private int mBarsCount = 0;

  public GoKart(String color) {
    mColor = color;
     }
  public int charge() {
    mBarsCount = MAX_BATTERY;
  }

  public String getColor() {
    return mColor;
  } 
}

1 Answer

Rob Bridges
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 Points

Hey there Cole,

I don't remember this challenge wanting us to import a console, however I could be wrong on that as it's been a bit since I've done it.

However the trouble that your code is telling you is that you told it that your charge method will return an int when you declared it.

A simple fix like changing this to

public void charge() 

will allow your code to skate on through just fine.

Thanks, let me know if this helps or not.