Error Codes Involving "'.class' and ';' Expected"


#1

I am not sure how to fix this code.
https://www.codecademy.com/courses/learn-java/projects/droid

Droid.java:47: error: '.class' expected
HAL.chargeBattery (int hours = 5)
^
Droid.java:47: error: ';' expected
HAL.chargeBattery (int hours = 5)
^
Droid.java:48: error: '.class' expected
HAL.hover (int feet = 1.5);
^
Droid.java:48: error: ';' expected
HAL.hover (int feet = 1.5);
^
4 errors


public class Droid {
  
    public Droid(int batteryLevel) {
      batteryLevel = 100;
    }
  
  public void activate() {
    System.out.println("Activated. How can I help you?");
    int batteryLevel = batteryLevel - 5;
    System.out.println("Battery level is: " + batteryLevel + " percent.");
  }
  
  public void chargeBattery (int hours) {
    System.out.println("Droid charging...");
    int batteryLevel = batteryLevel + hours;
    
    if (batteryLevel > 100) {
      batteryLevel = 100;
      System.out.println("Battery level is: " + batteryLevel + " percent.");
    }
    
    else {
      System.out.println("Battery level is: " + batteryLevel + " percent.");
    }
  }
  
  public int checkBatteryLevel (){
    System.out.println("Battery level is: " + batteryLevel + " percent.");
    return batteryLevel;
  }
  
  public void hover (int feet) {
    if (feet > 2) {
      System.out.println("Error! I cannot hover above 2 feet.");
    }
    
    else {
      System.out.println("Hovering...");
      int batteryLevel = batteryLevel - 20;
      System.out.println("Battery level is: " + batteryLevel + " percent.");
    }
  }
  
  public static void main(String[] args) {
    Droid HAL = new Droid();
    HAL.activate();
    HAL.chargeBattery (int hours = 5)
    HAL.hover (int feet = 1.5);
  }
}


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.