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

/tutorial/backtracking/logigram/var.e

http://github.com/tybor/Liberty
Specman e | 87 lines | 57 code | 12 blank | 18 comment | 2 complexity | 047844d540d72829258910d0e5637ad7 MD5 | raw file
 1-- See the Copyright notice at the end of this file.
 2--
 3class VAR
 4
 5creation {ANY}
 6	make
 7
 8feature {ANY}
 9	group: GROUP
10
11	name: STRING
12
13	item: ITEM
14
15	to_integer: INTEGER is
16		require
17			group.is_like_integer
18			not is_off
19		do
20			Result := item.to_integer
21		end
22
23	make (the_group: like group; the_name: like name) is
24		do
25			group := the_group
26			name := the_name
27		end
28
29	start is
30		do
31			if group.item_count = 0 then
32				item := Void
33			else
34				goto_index(0)
35			end
36		ensure
37			group.item_count > 0 /= is_off
38		end
39
40	is_off: BOOLEAN is
41		do
42			Result := item /= Void
43		ensure
44			Result = (item /= Void)
45		end
46
47	next is
48		require
49			not is_off
50		do
51			if item.index + 1 < group.item_count then
52				goto_index(item.index + 1)
53			else
54				item := Void
55			end
56		end
57
58	goto_index (idx: INTEGER) is
59		require
60			idx.in_range(0, group.item_count - 1)
61		do
62			group.goto_index(idx)
63			item := group.item
64		ensure
65			not is_off
66		end
67
68feature {}
69	value: INTEGER
70
71end -- class VAR
72--
73-- ------------------------------------------------------------------------------------------------------------------------------
74-- Copyright notice below. Please read.
75--
76-- This file is free software, which comes along with SmartEiffel. This software is distributed in the hope that it will be
77-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
78-- You can modify it as you want, provided this footer is kept unaltered, and a notification of the changes is added.
79-- You are allowed to redistribute it and sell it, alone or as a part of another product.
80--
81-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
82-- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
83--
84-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
85--
86-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
87-- ------------------------------------------------------------------------------------------------------------------------------