Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Person {
- private state ="normal" //cripple
- run() {
- if (this.state === "normal") {
- console.log("run")
- } else {
- console.log("hobble")
- }
- }
- }
- //vs
- abstract class AttemptRun {
- abstract run();
- }
- class NormalRun extends AttemptRun {
- run() {
- console.log("run")
- }
- }
- class CrippleRun extends AttemptRun {
- run() {
- console.log("hobble")
- }
- }
- class Person {
- protected runAbility: AttemptRun;
- run() {
- this.runAbility.run()
- }
- }
Add Comment
Please, Sign In to add comment