-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTask.java
48 lines (41 loc) · 1.3 KB
/
Task.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
public class Task {
int priority;
String name;
/*
Assignment number : 8
File Name : Task.java
Name: Ran Zaaroor
Student ID : 209374040
Email : [email protected]
*/
/**
* A standard constructor for the task class
*
* @param priority
* @param name
*/
public Task(int priority, String name){
this.name = name;
this.priority = priority;
}
/**
* Compares this task to another task.
* This task is consider smaller than the other task if and only if
* The priority of this task is smaller than the other task or the priorities are equal
* and the name of this task is smaller in the lexicographic ordering than the name of the other task.
*
* If this task is smaller returns a negative number. If this task is bigger return a positive number.
* If the tasks are equal return 0.
*
*
* @param other
* @return a negative/positive or zero number of this task is smaller/greater or equal to other
*/
public int compareTo(Task other) {
if (this.priority != other.priority) return this.priority - other.priority;
else {return this.name.compareTo(other.name);}
}
public String toString(){
return "task: " + this.name + ", priority: " + this.priority;
}
}