25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
967B

  1. interface Printable
  2. method print()
  3. method tag() as byte
  4. end interface
  5. interface Resettable
  6. method reset()
  7. end interface
  8. class Counter implements Printable, Resettable
  9. private word value
  10. public method init(start as word)
  11. self.value = start
  12. end method
  13. public method print()
  14. print self.value
  15. end method
  16. public method tag() as byte
  17. return 1
  18. end method
  19. public method reset()
  20. self.value = 0
  21. end method
  22. end class
  23. class Ticker implements Printable
  24. public method print()
  25. print 7
  26. end method
  27. public method tag() as byte
  28. return 2
  29. end method
  30. end class
  31. program Main
  32. var count as Counter
  33. var tick as Ticker
  34. var shown as Printable
  35. var zeroed as Resettable
  36. var ok as boolean
  37. count = new Counter(10)
  38. tick = new Ticker()
  39. shown = count
  40. shown.print()
  41. ok = shown.tag() = 1
  42. zeroed = count
  43. zeroed.reset()
  44. shown = tick
  45. shown.print()
  46. ok = shown.tag() = 2
  47. delete shown
  48. delete count
  49. end program

Powered by TurnKey Linux.