/** * A task with an assigned priority. You cannot change the * name or priority of a task once the task has been * created. * * @author Samuel A. Rebelsky * @version 1.0 of April 2000 */ public class PrioritizedTask implements Prioritized { // +--------+---------------------------------------- // | Fields | // +--------+ /** The name of the task. */ private String task; /** The priority assigned to the task. */ private int priority; // +--------------+-------------------------------------------- // | Constructors | // +--------------+ /** Create a new task of specified priority. */ public PrioritizedTask(String name, int prio) { this.task = name; this.priority = prio; } // PrioritizedTask(String,int) // +------------+---------------------------------------------- // | Extractors | // +------------+ /** Get the priority assigned to this task. */ public int getPriority() { return this.priority; } // getPriority() /** Get the name assigned to this task. */ public String getName() { return this.task; } // getName() /** Convert to a string in preparation for printing. */ public String toString() { return this.task + " (" + this.priority + ")"; } // toString() } // class PrioritizedTask