/tutorial/triangle/version4/point.e

http://github.com/tybor/Liberty · Specman e · 46 lines · 33 code · 7 blank · 6 comment · 0 complexity · 0bed21972987594b575a6eb70e483ad3 MD5 · raw file

  1. class POINT
  2. -- Description of POINTs objects.
  3. creation {ANY}
  4. make
  5. feature {ANY}
  6. x: REAL
  7. -- The `x' coordinate.
  8. y: REAL
  9. -- The `y' coordinate.
  10. translate (dx, dy: REAL) is
  11. -- To translate `Current' using `dx' and `dy'.
  12. do
  13. x := x + dx
  14. y := y + dy
  15. ensure
  16. x = dx + old x
  17. y = dy + old y
  18. end
  19. display_on (stream: OUTPUT_STREAM) is
  20. -- Display `Current' on the `stream'.
  21. require
  22. stream.is_connected
  23. do
  24. stream.put_string("POINT[")
  25. stream.put_real(x)
  26. stream.put_character(',')
  27. stream.put_real(y)
  28. stream.put_string("]%N")
  29. ensure
  30. stream.is_connected
  31. end
  32. feature {}
  33. make (vx, vy: REAL) is
  34. -- To create a new POINT.
  35. do
  36. x := vx
  37. y := vy
  38. end
  39. end -- class POINT