Created
March 8, 2012 19:27
-
-
Save robinedwards/2002862 to your computer and use it in GitHub Desktop.
extended appliance class
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 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