Notes
- Booleans are true or false values
- Comparison expressions generate booleans
- If statement run when the conditional evaluates to the boolean true
- Else if statements take in another conditional after the If statement
- Else statements runs when the conditional evaluates to false
- De Morgan's Law: (A∪B)’= A’∩B’, (A∩B)’= A’∪B’
public int getChargeStartTime (int chargeTime) {
int startHour = 0;
int lowPrice = 500_000;
for (int x = 0; x < 23; x++) {
if (lowPrice > getChargingCost(x, chargeTime)) {
lowPrice = getChargingCost(x, chargeTime);
startHour = x;
}
}
return startHour;
}
public boolean isStrictlyIncreasing () {
boolean increasing = true;
for (int i = 1; i < digitListSize(); i++) {
if (digitList.get(i-1) >= digitList.get(i)) {
increasing = false;
}
}
return increasing;
}
public boolean isBalanced(ArrayList<String> delimiters) {
int numOpen = 0, numClosed = 0;
for(String d : delimiters) {
if(d.equals(openDel))
numOpen++;
if(d.equals(closeDel))
numClosed++;
if(numClosed > numOpen)
return false;
}
return numOpen == numClosed;
}