Skip to content

Commit

Permalink
Rename Expression::hasHigherPriority() to canExecuteFirst
Browse files Browse the repository at this point in the history
  • Loading branch information
FourteenBrush committed Jun 20, 2024
1 parent e3b919c commit 2d41ba5
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public double solve() {

Assert.notNull(second.right, "unexpected trailing operator");

if (first.hasHigherPriority()) {
if (first.canExecuteFirst()) {
// f.e. 2*3+2
double firstOperand = first.solve();
double secondOperand = second.right.getValue();
Expand All @@ -108,7 +108,7 @@ private void shorten() {
LinkedCalculation next = current.next;
if (next != null) {
// we can only solve 'current' if its operator priority is higher than or equal to the next's operator priority
if (!current.hasHigherPriority()) continue;
if (!current.canExecuteFirst()) continue;
// unlink current
LinkedCalculation prev = current.prev;
double solved = current.solve();
Expand Down Expand Up @@ -183,7 +183,7 @@ public LinkedCalculation(Operand left) {
}

// we have a reference to the next calculation so no need to implement Comparable<LinkedCalculation>
public boolean hasHigherPriority() {
public boolean canExecuteFirst() {
return operator.getPriority() >= next.operator.getPriority();
}

Expand Down

0 comments on commit 2d41ba5

Please sign in to comment.