Guest User

Untitled

a guest
Nov 20th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. class Person {
  2. private state ="normal" //cripple
  3.  
  4. run() {
  5. if (this.state === "normal") {
  6. console.log("run")
  7. } else {
  8. console.log("hobble")
  9. }
  10. }
  11. }
  12.  
  13.  
  14. //vs
  15.  
  16. abstract class AttemptRun {
  17. abstract run();
  18. }
  19.  
  20.  
  21. class NormalRun extends AttemptRun {
  22. run() {
  23. console.log("run")
  24. }
  25. }
  26.  
  27. class CrippleRun extends AttemptRun {
  28. run() {
  29. console.log("hobble")
  30. }
  31. }
  32.  
  33. class Person {
  34. protected runAbility: AttemptRun;
  35.  
  36. run() {
  37. this.runAbility.run()
  38. }
  39. }
Add Comment
Please, Sign In to add comment