Created
October 11, 2020 17:36
-
-
Save dynoChris/2d5d44d2ddd8a12479a1c90c82f75c88 to your computer and use it in GitHub Desktop.
How to repeat task in Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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