command-pattern-queue
Version:
```typescript // command interface export interface ICommand { execute(): void unexecute(): void }
47 lines (32 loc) • 827 B
text/typescript
import {ICommand} from "../../lib/ICommand";
import {Counter} from "./Counter";
export class AddOneN1Command implements ICommand {
constructor(private readonly counter: Counter) {
}
execute(): void {
this.counter.n1++;
}
unexecute(): void {
this.counter.n1--;
}
}
export class AddTenN1Command implements ICommand {
constructor(private readonly counter: Counter) {
}
execute(): void {
this.counter.n1 += 10;
}
unexecute(): void {
this.counter.n1 -= 10;
}
}
export class AddFiveN1Command implements ICommand {
constructor(private readonly counter: Counter) {
}
execute(): void {
this.counter.n1 += 5;
}
unexecute(): void {
this.counter.n1 -= 5;
}
}