package tutor; import java.util.*; /** The Task interface represents any kind of activity * which may take some significant time. Tasks may succeed * or fail. A Task may have begun but not finished. In the {@linkplain tutor} * package a task is used by the {@linkplain TaskManager} class, * which queues a list of tasks and carries them out in a * Thread. * * An example of a Task is a {@linkplain tutor.SoundDownload} * */ public interface Task { //-------------------------------------------- /** begin the task whatever it is */ void begin(); //-------------------------------------------- /** reports if the task has finished or not */ boolean hasFinished(); //-------------------------------------------- /** returns the amount of time which the task took to * complete, in milliseconds */ long getWorkDuration(); //-------------------------------------------- /** the amount of time taken to complete in seconds */ float getWorkDurationInSeconds(); //-------------------------------------------- Date getStartTime(); //-------------------------------------------- Date getFinishTime(); //-------------------------------------------- /** reports if the task was completed successfully */ boolean wasSuccessful(); //-------------------------------------------- /** return a string describing the result of the task. This * should return something like 'success', 'failure' or * 'not started' */ String getResult(); //-------------------------------------------- /** prints a concise report about the state and result of * the task */ String print(); //-------------------------------------------- /** prints a more comprehensive report about the state and * result of the task */ String printReport(); } //-- Task