PageRenderTime 7ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/tutorial/triangle/version3/triangle.e

http://github.com/tybor/Liberty
Specman e | 63 lines | 45 code | 11 blank | 7 comment | 0 complexity | fcec626c8034ac7b06d0fb29cf641587 MD5 | raw file
 1class TRIANGLE
 2	-- Description of TRIANGLEs objects.
 3
 4creation {ANY}
 5	make
 6
 7feature {ANY}
 8	p1: POINT
 9			-- First point.
10
11	p2: POINT
12			-- Second point.
13
14	p3: POINT
15			-- Third point.
16
17	translate (dx, dy: REAL) is
18			-- To translate `Current' using `dx' and `dy'.
19		do
20			p1.translate(dx, dy)
21			p2.translate(dx, dy)
22			p3.translate(dx, dy)
23		end
24
25	display_on (stream: OUTPUT_STREAM) is
26			-- To display `Current' on the `stream'.
27		require
28			stream.is_connected
29		do
30			stream.put_string("TRIANGLE[%N%T")
31			p1.display
32			stream.put_string("%N%T")
33			p2.display
34			stream.put_string("%N%T")
35			p3.display
36			stream.put_string("%T]%N")
37		end
38
39feature {}
40	make (a, b, c: POINT) is
41			-- To create a new TRIANGLE.
42		require
43			a /= Void
44			b /= Void
45			c /= Void
46		do
47			p1 := a
48			p2 := b
49			p3 := c
50		ensure
51			p1 = a
52			p2 = b
53			p3 = c
54		end
55
56invariant
57	p1 /= Void
58
59	p2 /= Void
60
61	p3 /= Void
62
63end -- class TRIANGLE