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

***I HAVE WRITTEN THE CODE FOR THE FOLLOWING PROGRAM, I JUST NEED A SUITABLE JAV

ID: 3535538 • Letter: #

Question






***I HAVE WRITTEN THE CODE FOR THE FOLLOWING PROGRAM, I JUST NEED A SUITABLE JAVA DESIGN FOR THIS FOLLOWING PROGRAM CODE:*** PLEASE USE JAVA LANGUAGES WHEN DESIGNING***



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***


Priority class

public interface Priority

{

public void setPriority(int level);

public intgetPriority();

}

Task class

public class Task implements Priority

{

private String msg, priority;

private int level;

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

// Constructor: Creates a task and a priority level.

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

public Task ()

{

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 Task(String string, int i) {

// TODO Auto-generated constructor stub

}

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

// 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 intgetPriority()

{

return level;

}

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

// Returns a description of the task object.

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

public String toString()

{

return msg + " " + "Priority Level: " + level + " " + priority;

}

public voidsetmassage(String string) {

// TODO Auto-generated method stub

}

}

Main_imp class


public class main_imp{

public static void main(String arg[]){

Task> new Task("one",3);

Task two = new Task();

two.setPriority (1);

two.setmassage ("two");

System.out.println(one.toString());

System.out.println(two.toString());

}

}


Explanation / Answer

In Task.java:
public class Task implements Priority {

private int priority;

@Override
public int getPriority() {
return priority;
}

@Override
public void setPriority(int p) {
priority = p;
}


public static void main(String[] args) {

Task t = new Task();
t.setPriority(99);
System.out.println("priority is " + t.getPriority());


}



}


In Priority.java:


public interface Priority {

int getPriority();
void setPriority(int p);

}