Build Your Own Droid - 12 Error messages


#1



https://www.codecademy.com/en/courses/learn-java/projects/droid?link_content_target=interstitial_project


What am I doing wrong? I'm stuck on "Your Own Droid' and can't seem to figure out what I am doing wrong even when I've read the error messages.Any detailed help would be great! Thanks, Jacob

Droid.java:13: error: invalid method declaration; return type required
public chargebattery (int hours){
^
Droid.java:27: error: invalid method declaration; return type required
public hover (int feet){
^
Droid.java:36: error: illegal start of expression
public static void main (String args[]){
^
Droid.java:36: error: illegal start of expression
public static void main (String args[]){
^
Droid.java:36: error: ';' expected
public static void main (String args[]){
^
Droid.java:36: error: ')' expected
public static void main (String args[]){
^
Droid.java:36: error: illegal start of expression
public static void main (String args[]){
^
Droid.java:36: error: ';' expected
public static void main (String args[]){
^
Droid.java:36: error: illegal start of expression
public static void main (String args[]){
^
Droid.java:36: error: ';' expected
public static void main (String args[]){
^
Droid.java:38: error: not a statement
droid.activate;
^
Droid.java:47: error: class, interface, or enum expected
} // <- public class droid
^
12 errors


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



}


#2

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