PageRenderTime 49ms CodeModel.GetById 43ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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