Skip to content

Instantly share code, notes, and snippets.

@dynoChris
Created October 11, 2020 17:36
Show Gist options
  • Select an option

  • Save dynoChris/2d5d44d2ddd8a12479a1c90c82f75c88 to your computer and use it in GitHub Desktop.

Select an option

Save dynoChris/2d5d44d2ddd8a12479a1c90c82f75c88 to your computer and use it in GitHub Desktop.

Revisions

  1. dynoChris created this gist Oct 11, 2020.
    29 changes: 29 additions & 0 deletions Repeater.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    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;
    }

    }