Last active
June 26, 2018 17:13
-
-
Save eduardomoroni/07ad2216be4d81a09e82009770b3869f to your computer and use it in GitHub Desktop.
Counter interactor
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
import { Counter } from "../entities"; | |
export class CounterInteractor { | |
higherBound: number = 10; | |
counter: Counter; | |
constructor( | |
startNumber: number, | |
higherBound: number = 10 | |
) { | |
this.counter = new Counter(startNumber); | |
this.higherBound = higherBound; | |
} | |
increment(qty?: number): Counter { | |
this.counter.increment(qty); | |
if (this.counter.count >= this.higherBound) { | |
this.counter = new Counter(this.higherBound); | |
} | |
return this.counter; | |
} | |
decrement(qty?: number): Counter { | |
// Omitted for simplicity | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment