Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • main
1 result

Target

Select target project
  • ethan.robert.etu/dev-oo
1 result
Select Git revision
  • main
1 result
Show changes
Commits on Source (6)
clean:
rm -rvf bin/*
tp03: clean
javac -cp res/tp03_res.jar:. src/tp03/*.java -d bin
package tp03;
package tp03.ex01;
public class Card {
......
package tp03;
package tp03.ex01;
public enum Color {
CLUB, DIAMOND, HEART, SPADE;
......
package tp03;
package tp03.ex01;
public enum Rank {
SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE;
......
package tp03.ex02;
import java.time.LocalDate;
public class Task {
private int taskID;
private LocalDate creationDate;
private LocalDate deadline;
private TaskStatus status;
private String description;
private int duration;
private static int counter = 0;
public Task(String description, int duration) {
this.taskID = Task.counter;
Task.counter++;
this.creationDate = LocalDate.now();
this.deadline = this.creationDate.plusDays(10);
this.duration = duration;
this.description = description;
this.status = TaskStatus.TODO;
}
public Task(String description, LocalDate creation, LocalDate deadline, int duration) {
this.taskID = Task.counter=
Task.counter++;
this.creationDate = creation;
this.deadline = deadline;
this.duration = duration;
this.description = description;
this.status = TaskStatus.TODO;
}
public String toString() {
return "T" + this.taskID + " = " + this.description + ":" + this.status + "(" + this.duration + "):" + this.deadline;
}
public void changeStatus(TaskStatus st) {
this.status = st;
}
public void changeStatus() {
for (int i = 0; i < TaskStatus.values().length; i++) {
if (TaskStatus.values()[i].equals(this.status)) {
// Use modulo to avoid errors
this.status = TaskStatus.values()[i+1 % TaskStatus.values().length - 1];
}
}
}
public boolean isLate() {
LocalDate now = LocalDate.now();
if (this.deadline.compareTo(now) < 0) {
return true;
}
return false;
}
public void delay(int nbDays) {
this.deadline = this.deadline.plusDays(nbDays);
}
}
\ No newline at end of file
package tp03.ex02;
public enum TaskStatus {
TODO, ONGOING, DELAYED, FINISHED;
}
\ No newline at end of file
package tp03;
package tp03.ex01;
public class UseCard {
public static void main(String[] args) {
......
package tp03.ex01;
import java.time.LocalDate;
import java.time.chrono.ChronoLocalDate;
import java.util.Random;
......
package tp03.ex02;
import java.time.LocalDate;
public class UseTask {
public static void main (String[] args) {
Task t1 = new Task("Finir exo1", 1);
Task t2 = new Task("Finir exo2", LocalDate.of(2025, 02, 01), LocalDate.of(2025, 03, 01), 2);
System.out.println(t1);
System.out.println(t2);
t1.changeStatus();
t2.changeStatus(TaskStatus.FINISHED);
System.out.println(t1);
System.out.println(t2);
// Test of isLate()
Task t3 = new Task("Finir exo3", LocalDate.of(2025, 02, 01), LocalDate.of(2025, 02, 10), 5);
Task t4 = new Task("Finir exo4", LocalDate.of(2025, 02, 01), LocalDate.of(2025, 02, 10), 5);
System.out.println(t3 + ", " + t3.isLate());
System.out.println(t4 + ", " + t4.isLate());
t3.changeStatus(TaskStatus.FINISHED);
t4.delay(30);
System.out.println(t3 + ", " + t3.isLate());
System.out.println(t4 + ", " + t4.isLate());
}
}
\ No newline at end of file