Java Java Objects Harnessing the Power of Objects Overload Methods

Sebastian Manczak
Sebastian Manczak
3,199 Points

Java objects, laps to go question

I am stuck here. Could I please get a few hints

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 String getColor() {
    return color;
  }
  public void charge() {
    barCount = MAX_BARS;
  }
  public boolean isBatteryEmpty() {
    return barCount == 0;
  }
  public boolean isFullyCharged() {
    return MAX_BARS == barCount;
  }
  public void drive (int lapsDriven) {
    lapsDriven += lapsDriven;
  }
}

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 50,888 Points

The error message tells you what to do: Bummer: Ensure you use the -= shorthand to decrement barCount by the new laps argument. Include this in your drive method.