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 Increment and Decrement

Gaurang Kotasthane
Gaurang Kotasthane
1,394 Points

In your newly created drive method, increment the new lapsDriven variable by 1. Use the incrementing shorthand to increa

Its says " Oops ! It looks like Task1 is no longer passing !" I don't understand what's wrong? task 1 was to create a new private field named lapsDriven;

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

  public GoKart(String color) {
    this.color = color;
  }
  public void drive() {
   lapsDriven++; 
  }



  public String getColor() {
    return color;
  }

  public void charge() {
    barCount = MAX_BARS;
  }

  public boolean isBatteryEmpty() {
    return barCount == 0;
  }

  public boolean isFullyCharged() {
    return MAX_BARS == barCount;
  }
  private int lapsDriven; {
    lapsDriven=lapsDriven++;
   }
  public int drive() {
   lapsDriven++ 
  }

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Very often, when you have a Bummer! message that states that Task <number> is no longer passing, it's because you've introduced a syntax error into your code. That is the case here. I'm not sure if your last curly brace is just not showing, or if it's missing completely, but in the code shown in your question there's a missing curly brace.

But before that, there's a missing semicolon.

  public int drive() {
   lapsDriven++ ;  // Note the addition of the semicolon on this line
  }
} // Addition of closed curly brace

Because of the syntax errors, your code cannot be compiled which makes the Bummer message accurate, but a bit vague perhaps.

Hope this helps! :sparkles:

Carrie Baynes
Carrie Baynes
467 Points

private int lapsDriven() { lapsDriven++; } public void drive() { drive.lapsDriven++; }