-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmartAppliance.java
More file actions
37 lines (30 loc) · 1.26 KB
/
SmartAppliance.java
File metadata and controls
37 lines (30 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
public class SmartAppliance extends Appliance {
private double lowModeReduction;
boolean onLow;
private int onWattage = super.getOnWattage();
public SmartAppliance(boolean type, int onWattage, double probability, int location, String applianceId,
double lowModeReduction) { // initializes SmartAppliance object
super(type, onWattage, probability, location, applianceId);
this.onLow = false;
this.lowModeReduction = lowModeReduction;
}
public void setOnLow(boolean onLow) { // setter method for onLow boolean
this.onLow = onLow;
}
public boolean getOnLow() {
return this.onLow;
}
@Override
public String toString() {
return super.toString() + "," + lowModeReduction;
}
public int getOnWattage() { // checks to see whether to return normal watts if onLow is false, or low watts
// if onLow is true
if (onLow == true) {
return (int) ((double) (onWattage) * lowModeReduction); // returns low wattage (normal onWatts times lowMode
// percentage)
} else {
return onWattage; // returns normal watts if onLow is false
}
}
}