Skip to content

Instantly share code, notes, and snippets.

@dynoChris
Created October 11, 2020 17:36
Show Gist options
  • Save dynoChris/2d5d44d2ddd8a12479a1c90c82f75c88 to your computer and use it in GitHub Desktop.
Save dynoChris/2d5d44d2ddd8a12479a1c90c82f75c88 to your computer and use it in GitHub Desktop.
How to repeat task in Java
public class Repeater {
private final int mEach;
private int mLap;
public Repeater(int each) {
this.mEach = each;
this.mLap = each;
}
public int getLap() {
return mLap;
}
public boolean repeat() {
if (mLap == mEach) {
mLap = 1;
return true;
} else {
mLap++;
return false;
}
}
public void reset() {
mLap = mEach;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment