Skip to content

Instantly share code, notes, and snippets.

@robinedwards
Created March 8, 2012 19:27
Show Gist options
  • Save robinedwards/2002862 to your computer and use it in GitHub Desktop.
Save robinedwards/2002862 to your computer and use it in GitHub Desktop.
extended appliance class
public abstract class ExtendedAppliance implements Appliance {
protected Double demand;
protected String name;
protected Integer id;
protected boolean turnedOn = false;
public Double demandUsedFor(Long seconds) {
if (turnedOn)
return (demand * (seconds / (3600)));
else
return 0.0;
}
public void turnOff() {
turnedOn = false;
}
public void turnOn() {
turnedOn = true;
}
public boolean isTurnedOn() {
return turnedOn;
}
public Double getDemand() {
return demand;
}
public String getName() {
return name;
}
public Integer getId() {
return id;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment