Skip to content

Commit

Permalink
Update need-for-speed analyzer for changed function name
Browse files Browse the repository at this point in the history
  • Loading branch information
gigaSproule committed Jul 16, 2024
1 parent bea68a2 commit 47fbecd
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class RaceTrackClassAnalyzer extends VoidVisitorAdapter<OutputCollector> {

@Override
public void visit(MethodDeclaration node, OutputCollector output) {
if (node.getNameAsString().equals("tryFinishTrack") && hasLoop(node)) {
if (node.getNameAsString().equals("canFinishRace") && hasLoop(node)) {
output.addComment(new AvoidLoops());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RaceTrack {
this.distance = distance;
}

public boolean tryFinishTrack(NeedForSpeed car) {
public boolean canFinishRace(NeedForSpeed car) {
return ((double) distance / car.getSpeed()) <= (car.getCurrentBattery() / car.getBatteryDrain());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class RaceTrack {
this.distance = distance;
}

public boolean tryFinishTrack(NeedForSpeed car) {
public boolean canFinishRace(NeedForSpeed car) {
for (int i = 0; i < this.distance / car.getSpeed(); i++) {
car.drive();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RaceTrack {
this.distance = distance;
}

public boolean tryFinishTrack(NeedForSpeed car) {
public boolean canFinishRace(NeedForSpeed car) {
return ((double) distance / car.getSpeed()) <= (car.getCurrentBattery() / car.getBatteryDrain());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RaceTrack {
this.distance = distance;
}

public boolean tryFinishTrack(NeedForSpeed car) {
public boolean canFinishRace(NeedForSpeed car) {
return ((double) distance / car.getSpeed()) <= (car.getCurrentBattery() / car.getBatteryDrain());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class RaceTrack {
this.distance = distance;
}

public boolean tryFinishTrack(NeedForSpeed car) {
public boolean canFinishRace(NeedForSpeed car) {

while (!car.batteryDrained()) {
car.drive();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class RaceTrack {
this.distance = distance;
}

public boolean tryFinishTrack(NeedForSpeed car) {
public boolean canFinishRace(NeedForSpeed car) {
return ((double) distance / car.getSpeed()) <= (car.getCurrentBattery() / car.getBatteryDrain());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class RaceTrack {
this.distance = distance;
}

public boolean tryFinishTrack(NeedForSpeed car) {
public boolean canFinishRace(NeedForSpeed car) {
return ((double) distance / car.getSpeed()) <= (car.getCurrentBattery() / car.getBatteryDrain());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class RaceTrack {
this.distance = distance;
}

public boolean tryFinishTrack(NeedForSpeed car) {
public boolean canFinishRace(NeedForSpeed car) {

while (!car.batteryDrained()) {
car.drive();
Expand Down

0 comments on commit 47fbecd

Please sign in to comment.