The Eiffel language many features to make this possible such as Design by Contract, Multiple Inheritance, Method Rename and so on.
While doing Eiffel I wanted to try out a Small thread based code I did in Java in Eiffel. The code just takes in a String and prints one character after another in the console like in those Action Movies where the secret location name will be printed.
After some reading I managed to do this with the following code in Eiffel.
slow_prompt(text : STRING) is
require
valid_text : text /= void
local
counter : INTEGER
do
from
counter := 1;
until
counter > text.count
loop
io.put_character (text.at (counter));
sleep(7812500); -- Sleep for 7812500 nano seconds
counter := counter + 1;
end
end
For this method to work however the class EXECUTION_ENVIRONMENT needs to facility inherited.
No comments:
Post a Comment