Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created October 15, 2020 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/a418cf12dc8f903406b8a9c92c66d957 to your computer and use it in GitHub Desktop.
Save codecademydev/a418cf12dc8f903406b8a9c92c66d957 to your computer and use it in GitHub Desktop.
Codecademy export
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