This commit is contained in:
Anthony Stirling
2023-12-29 20:48:21 +00:00
parent 610ff22abe
commit 1b2df20fdd
12 changed files with 79 additions and 37 deletions

View File

@@ -1,27 +1,27 @@
package stirling.software.SPDF.model;
public class AttemptCounter {
private int attemptCount;
private long firstAttemptTime;
private long lastAttemptTime;
public AttemptCounter() {
this.attemptCount = 1;
this.firstAttemptTime = System.currentTimeMillis();
this.lastAttemptTime = System.currentTimeMillis();
}
public void increment() {
this.attemptCount++;
this.firstAttemptTime = System.currentTimeMillis();
this.lastAttemptTime = System.currentTimeMillis();
}
public int getAttemptCount() {
return attemptCount;
}
public long getFirstAttemptTime() {
return firstAttemptTime;
public long getlastAttemptTime() {
return lastAttemptTime;
}
public boolean shouldReset(long ATTEMPT_INCREMENT_TIME) {
return System.currentTimeMillis() - firstAttemptTime > ATTEMPT_INCREMENT_TIME;
return System.currentTimeMillis() - lastAttemptTime > ATTEMPT_INCREMENT_TIME;
}
}