I Get so many errors and can't seem to find out what's wrong. Please help


#1



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


Droid.java:38: error: illegal start of expression
public int checkBatteryLevel() {
^
Droid.java:38: error: ';' expected
public int checkBatteryLevel() {
^
Droid.java:45: error: illegal start of expression
public void hover(int feet) {
^
Droid.java:45: error: illegal start of expression
public void hover(int feet) {
^
Droid.java:45: error: ';' expected
public void hover(int feet) {
^
Droid.java:45: error: ';' expected
public void hover(int feet) {
^
Droid.java:61: error: illegal start of expression
public static void main(String[] args){
^
Droid.java:61: error: illegal start of expression
public static void main(String[] args){
^
Droid.java:61: error: ';' expected
public static void main(String[] args){
^
Droid.java:61: error: '.class' expected
public static void main(String[] args){
^
Droid.java:61: error: ';' expected
public static void main(String[] args){
^
much more

Replace this line with your code. 
public class Droid {

  int batteryLevel;
  
  public Droid() {
  
 int 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 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() {
 
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" + feet);
      
      batteryLevel = batteryLevel - 20;
      
      System.out.println("Battery level is: " +  batteryLevel + "percent");
      
    }            
   }                 
    public static void main(String[] args){
      
      Droid droid = new Droid();
       droid.activate();
     droid.chargeBattery(5);
     droid.hover(1);
      
    }


#2

@arielovin
Maybe reading the Book....

Found with google search
== the Book ==
java class define site:docs.oracle.com
https://docs.oracle.com/javase/tutorial/java/javaOO/classdecl.html
https://docs.oracle.com/javase/tutorial/java/concepts/class.html


#3

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