/tutorial/triangle/version3/point.e

http://github.com/tybor/Liberty · Specman e · 42 lines · 29 code · 7 blank · 6 comment · 0 complexity · f9ba1754f88723f58dc358b0b496df42 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 is
  20. -- Display `Current' on `io'.
  21. do
  22. io.put_string("POINT[")
  23. io.put_real(x)
  24. io.put_character(',')
  25. io.put_real(y)
  26. io.put_string("]%N")
  27. end
  28. feature {}
  29. make (vx, vy: REAL) is
  30. -- To create a new POINT.
  31. do
  32. x := vx
  33. y := vy
  34. end
  35. end -- class POINT