I'm trying finish my method 'priority' which should return the priority of the Task. and make it return null if the specified name does not exist (as shown in the main). I've tried iterating through the ArrayList, but i don't think this is the way to do it. Is there anyone who can help me out?
class Task
{
public static final ArrayList<Task> ALL_TASKS = new ArrayList<>();
private String name;
private Integer priority;
public Task(String name, Integer priority)
{
this.name = name;
this.priority = priority;
ALL_TASKS.add(this);
}
@Override public String toString()
{
return "name: " + this.name + "\tpriority: " + this.priority;
}
}
class Main
{
public static void main(String[] arguments)
{
new Task("Clean", 5);
new Task("Dishwash", 4);
new Task("Study", 1);
System.out.println(Task.priority("Dishwash"));
System.out.println(Task.priority("Vacuumclean"));
}
}
main?