Error msg


#1


https://www.codecademy.com/courses/learn-java/projects/droid#

Droid.java:1: error: '{' expected
public class Droid(){
^
1 error


public class Droid(){
  int batteryLevel=100;

  public void activate(){
    System.out.println("Acctivated. How can I help you?");
    batteryLevel=batteryLevel-5;
    System.out.println("Battery level is:" + batteryLevel+"percent");
  }
  public void chargeBattery(int hours){
    System.out.println("Droid charging");
    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(){
      return batteryLevel;
    }
    public void hover(int feet){
      if(feet>2){
        System.out.println("Error!");
      }
      else{
        System.out.println("Hovering"+feet);
        batteryLevel=batteryLevel-20;
        System.out.println("Battery level is:" +batteryLevel+"percent");
      }
    } 
  public static void main(String[] args){
    Droid myDroid=new Droid();
    myDroid.activate();
    myDroid.chargeBattery(5);
    myDroid.checkBatteryLevel();
    myDroid.hover(1);
  }
}

I think I've been inserting '{' correctly. But somehow this error msg appeared.

I'd be glad if somebody tells me the reason.

Please.


#2

It was just a problem of deleting '()' after 'Droid'...


#3

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