/tutorial/triangle/version2/triangle.e

http://github.com/tybor/Liberty · Specman e · 49 lines · 33 code · 10 blank · 6 comment · 0 complexity · 180ec9b12f3d04dc77610d38f423e570 MD5 · raw file

  1. class TRIANGLE
  2. -- Description of TRIANGLEs objects.
  3. creation {ANY}
  4. make
  5. feature {ANY}
  6. p1: POINT
  7. -- First point.
  8. p2: POINT
  9. -- Second point.
  10. p3: POINT
  11. -- Third point.
  12. translate (dx, dy: REAL) is
  13. -- To translate the `Current' TRIANGLE.
  14. do
  15. p1.translate(dx, dy)
  16. p2.translate(dx, dy)
  17. p3.translate(dx, dy)
  18. end
  19. feature {}
  20. make (a, b, c: POINT) is
  21. -- To create a new TRIANGLE.
  22. require
  23. a /= Void
  24. b /= Void
  25. c /= Void
  26. do
  27. p1 := a
  28. p2 := b
  29. p3 := c
  30. ensure
  31. p1 = a
  32. p2 = b
  33. p3 = c
  34. end
  35. invariant
  36. p1 /= Void
  37. p2 /= Void
  38. p3 /= Void
  39. end -- class TRIANGLE