tobjects.nim 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. type
  2. TBase = object of RootObj
  3. x, y: int
  4. TSubclassKind = enum ka, kb, kc, kd, ke, kf
  5. TSubclass = object of TBase
  6. case c: TSubclassKind
  7. of ka, kb, kc, kd:
  8. a, b: int
  9. of ke:
  10. d, e, f: char
  11. else: nil
  12. n: bool
  13. type
  14. TMyObject = object of RootObj
  15. case disp: range[0..4]
  16. of 0: arg: char
  17. of 1: s: string
  18. else: wtf: bool
  19. var
  20. x: TMyObject
  21. var
  22. global: int
  23. var
  24. s: string
  25. r: float = 0.0
  26. i: int = 500 + 400
  27. case i
  28. of 500..999: write(stdout, "ha!\n")
  29. of 1000..3000, 12: write(stdout, "ganz schön groß\n")
  30. of 1, 2, 3: write(stdout, "1 2 oder 3\n")
  31. else: write(stdout, "sollte nicht passieren\n")
  32. case readLine(stdin)
  33. of "Rumpf": write(stdout, "Hallo Meister!\n")
  34. of "Andreas": write(stdout, "Hallo Meister!\n")
  35. else: write(stdout, "Nicht mein Meister!\n")
  36. global = global + 1
  37. write(stdout, "Hallo wie heißt du? \n")
  38. s = readLine(stdin)
  39. i = 0
  40. while i < len(s):
  41. if s[i] == 'c': write(stdout, "'c' in deinem Namen gefunden\n")
  42. i = i + 1
  43. write(stdout, "Du heißt " & s)