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

/tutorial/parking/car.e

http://github.com/tybor/Liberty
Specman e | 37 lines | 28 code | 6 blank | 3 comment | 0 complexity | c0c648fec76182855d8f3e110e7e6ebc MD5 | raw file
 1class CAR
 2
 3creation {PARKING}
 4	make
 5
 6feature {ANY}
 7	number: INTEGER
 8			-- The number of the CAR.
 9
10	arrival_time: DATE
11			-- Of this CAR in the parking.
12
13	price (departure_time: DATE; hour_price: REAL): REAL is
14			-- Compute the price to pay according to `departure_time' and `hour_price'.
15		require
16			departure_time >= arrival_time
17		local
18			nb_min: TUPLE[INTEGER, INTEGER]
19		do
20			nb_min := arrival_time.day_night_to(departure_time)
21			Result := (hour_price / 4 * nb_min.second + hour_price * nb_min.first) / 60
22		end
23
24feature {}
25	make (n: like number; at: like arrival_time) is
26		require
27			n > 0
28			at /= Void
29		do
30			number := n
31			arrival_time := at
32		ensure
33			number = n
34			arrival_time = at
35		end
36
37end -- class CAR