Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a Java interface called Priority that includes two methods: setPriority a

ID: 3535351 • Letter: D

Question

Design a Java interface called Priority that includes two methods:
setPriority and getPriority. The interface should define
a way to establish numeric priority among a set of objects. Design
and implement a class called Task that represents a task (such as
on a to-do list) that implements the Priority interface. Create a
driver class to exercise some Task objects.


****The code is not compiling****


*****I need help with the main method****


Here is what I have so far:


public interface Priority
{
public void setPriority(int level);
public int getPriority();
}




public class Task implements Priority
{
private String msg, priority;
private int level;

//-----------------------------------------------------
// Constructor: Creates a task and a priority level.
//-----------------------------------------------------
public Task (String msg, int level)
{
this.msg = msg;
this.level = level;

if (level == 1)
priority = "Critical";
if (level == 2)
priority = "Very Important";
if (level == 3)
priority = "Normal";
if (level == 4)
priority = "Low";
if (level == 5)
priority = "Not Important";
}

//-----------------------------------------------------
// Sets the priority level.
//-----------------------------------------------------
public void setPriority (int level)
{
this.level = level;

if (level == 1)
priority = "Critical";
if (level == 2)
priority = "Very Important";
if (level == 3)
priority = "Normal";
if (level == 4)
priority = "Low";
if (level == 5)
priority = "Not Important";
}

//-----------------------------------------------------
// Returns the priority level.
//-----------------------------------------------------
public int getPriority()
{
return level;
}

//-----------------------------------------------------
// Returns a description of the task object.
//-----------------------------------------------------
public String toString()
{
return msg + " " + "Priority Level: " + level + " " + priority;
}
}



Explanation / Answer


public interface Priority
{
public void setPriority(int level);
public int getPriority();
}
//-------------------------------------------------------


public class Task implements Priority
{
private String msg, priority;
private int level;
public Task ()
{
System.out.println("");
}
public Task (String msg, int level)
{
this.msg = msg;
this.level = level;

if (level == 1)
priority = "Critical";
if (level == 2)
priority = "Very Important";
if (level == 3)
priority = "Normal";
if (level == 4)
priority = "Low";
if (level == 5)
priority = "Not Important";
}
public void setmassage (String mas)
{
msg=mas;
}
public void setPriority (int level)
{
this.level = level;

if (level == 1)
priority = "Critical";
if (level == 2)
priority = "Very Important";
if (level == 3)
priority = "Normal";
if (level == 4)
priority = "Low";
if (level == 5)
priority = "Not Important";
}

public int getPriority()
{
return level;
}

public String toString()
{
return (msg + " " + "Priority Level: " + level + " " + priority);
}
}

//------------------------------------------

public class main_imp{
public static void main(String arg[]){
Task Task("one",3);
Task two = new Task();
two.setPriority (1);
two.setmassage ("two");
System.out.println(one.toString());
System.out.println(two.toString());
}


}