Skip to content

Instantly share code, notes, and snippets.

@eduardomoroni
Last active June 26, 2018 17:13
Show Gist options
  • Save eduardomoroni/07ad2216be4d81a09e82009770b3869f to your computer and use it in GitHub Desktop.
Save eduardomoroni/07ad2216be4d81a09e82009770b3869f to your computer and use it in GitHub Desktop.
Counter interactor
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