-
-
Save codecademydev/a418cf12dc8f903406b8a9c92c66d957 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Droid{ | |
String name; | |
int batteryLevel; | |
public Droid (String droidName) { | |
name = droidName; | |
batteryLevel = 100; | |
} | |
public String toString(){ | |
return ("Hello, I'm the droid:" + name); | |
} | |
public void performTask(String task){ | |
System.out.println(name + " is performing task " + task); | |
batteryLevel -=10; | |
} | |
public void energyReport(){ | |
System.out.println("The current battery level is: " + batteryLevel); | |
} | |
public static void main (String[]args){ | |
Droid codey = new Droid("Codey"); | |
System.out.println(codey); | |
codey.performTask ("Tickling."); | |
codey.energyReport(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment