我正在编写一个以埃菲尔语言编写的计划软件,我创建了下面的代码,但我不太确定应该为这个班级指定哪种后置条件和/或前提条件“例程。埃菲尔合同怀疑
如果你能为此提供语法提示,那将会很棒,因为我不是埃菲尔语言的主人,而且它的关键字仍然有点棘手&在我目前的知识水平下很难理解。
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
那么,你的问题到底是什么?你有问题提出合同或用埃菲尔表达他们吗? – undefined
是的,我在埃菲尔代表他们时遇到问题,因为我不明白哪种语法表达式,关键字等必须使用,并且按照哪种顺序,我有一本书但没有足够的时间仔细阅读,我的老板是推动我尽快生成新的代码。 –