我正在編寫一個以埃菲爾語言編寫的計劃軟件,我創建了下面的代碼,但我不太確定應該爲這個班級指定哪種後置條件和/或前提條件「例程。埃菲爾合同懷疑
如果你能爲此提供語法提示,那將會很棒,因爲我不是埃菲爾語言的主人,而且它的關鍵字仍然有點棘手&在我目前的知識水平下很難理解。
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
是的,我在埃菲爾代表他們時遇到問題,因爲我不明白哪種語法表達式,關鍵字等必須使用,並且按照哪種順序,我有一本書但沒有足夠的時間仔細閱讀,我的老闆是推動我儘快生成新的代碼。 –