/tutorial/number/example2.e

http://github.com/tybor/Liberty · Specman e · 38 lines · 28 code · 5 blank · 5 comment · 0 complexity · 4aa9957ca0a7e56f00d82c5a78b4f657 MD5 · raw file

  1. class EXAMPLE2
  2. --
  3. -- To start with NUMBERs, just compile an run it :
  4. --
  5. -- compile -o example2 -boost example2
  6. --
  7. create {ANY}
  8. make
  9. feature {ANY}
  10. make
  11. local
  12. n1, n2, n3: NUMBER
  13. do
  14. n1 := ("1/3").to_number
  15. n2 := 1.to_number / 3.to_number
  16. n3 := n1 + n2
  17. io.put_number(n1)
  18. io.put_string(" + ")
  19. io.put_number(n2)
  20. io.put_string(" = ")
  21. io.put_number(n3)
  22. io.put_new_line
  23. io.put_number(n1)
  24. io.put_string(" + ")
  25. io.put_number(n3)
  26. io.put_string(" = ")
  27. io.put_number(n1 + n3)
  28. io.put_string("[
  29. Do you like NUMBERs ?
  30. Have a look at example #3 to know more about NUMBERs.
  31. ]")
  32. end
  33. end -- class EXAMPLE2