/tutorial/triangle/version2/example3.e

http://github.com/tybor/Liberty · Specman e · 46 lines · 38 code · 5 blank · 3 comment · 0 complexity · 98df4acad317386d5fd550e2d1be3af6 MD5 · raw file

  1. class EXAMPLE3
  2. -- You can also compile this code without -sedb (there's an output)
  3. create {ANY}
  4. main
  5. feature {ANY}
  6. main
  7. local
  8. x, y, z: POINT; t: TRIANGLE
  9. do
  10. create x.make(1.0, 2.0)
  11. point_display(x)
  12. create y.make(3.0, 4.0)
  13. point_display(y)
  14. create z.make(5.0, 6.0)
  15. point_display(z)
  16. create t.make(x, y, z)
  17. triangle_display(t)
  18. t.translate(1, 2)
  19. triangle_display(t)
  20. -- It is too bad (i.e. not object oriented).
  21. -- Have a look at version3 of class TRIANGLE
  22. end
  23. triangle_display (t: TRIANGLE)
  24. do
  25. io.put_string("TRIANGLE[%N%T")
  26. point_display(t.p1)
  27. io.put_string("%N%T")
  28. point_display(t.p2)
  29. io.put_string("%N%T")
  30. point_display(t.p3)
  31. io.put_string("%T]%N")
  32. end
  33. point_display (p: POINT)
  34. do
  35. io.put_string("POINT[")
  36. io.put_real(p.x)
  37. io.put_character(',')
  38. io.put_real(p.y)
  39. io.put_string("]%N")
  40. end
  41. end -- class EXAMPLE3