我正在开发一个用 Eiffel 语言编写的规划软件,我创建了以下代码,但我不太确定应该为此类的例程指定哪种后置条件和/或前置条件。
如果您可以为此提供语法提示,那就太好了,因为我不是埃菲尔语言的大师,而且以我目前的知识水平,它的关键字仍然有点棘手且难以理解。
class TIME
feature -- Initialization
make (one_hour, one_min, one_sec: NATURAL_8)
-- Setup ‘hour’, ‘minute’, and ‘seconds’ with
-- ‘one_hour’, ‘one_min’, and ‘one_sec’, as corresponds.
require
do
hour := one_hour
minute := one_min
second := one_sec
ensure
end
feature -- Setters
set_hour (one_hour: NATURAL_8)
-- Updates `hour' w/ value ‘one_hour’.
require
do
hour := one_hour
ensure
end
set_min (one_min: NATURAL_8)
-- Updates `minute' w/ value ‘one_min’.
require
do
minute := one_min
ensure
end
set_sec (one_sec: NATURAL_8)
-- Updates `second' w/ value ‘one_sec’.
require
do
second := one_seg
ensure
end
feature -- Operation
tick
-- Counts a tick for second cycle, following 24 hr format
-- During the day, “tick” works as follows
-- For example, the next second after 07:28:59 would be
-- 07:29:00. While the next second of 23:59:59
-- is 00:00:00.
do
ensure
end
feature -- Implementation
hour: NATURAL_8
minute: NATURAL_8
second: NATURAL_8
invariant
range_hour: hour < 24
range_minute: minute < 60
range_second: second < 60
end