I need help with the build a droid project

Here’s the link: https://www.codecademy.com/courses/learn-java/projects/build-a-droid

I keep getting this error:
Droid.java:15: error: missing return statement
}
^
1 error

This is my code:

public class Droid {

int batteryLevel;
String name;

//constructor
public Droid(String droidName) {
name = droidName;
batteryLevel = 100;
}

public String performTask(String task) {
System.out.println(name + " is performing task: " + task);
batteryLevel = batteryLevel - 10;
}

public String toString() {
return "Hey there, I’m the droid: " + name;
}

public static void main(String args) {
Droid myDroid = new Droid(“Codey”);
System.out.println(myDroid.name);
myDroid.performTask(“running”);
}

}

Any help would be appreciated

When you write public String someFunc(){}, that function needs to return a String. If it doesn’t, an error will be thrown.

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