Commit d153cf1c authored by Saad MAHBOUBI's avatar Saad MAHBOUBI 💬
Browse files

restauration

parent 6cb7d95d
Pipeline #27328 passed with stages
in 3 minutes and 29 seconds
package fr.unantes.l3.construction.events; package fr.unantes.l3.construction.events;
import java.time.Period; import org.checkerframework.checker.nullness.qual.NonNull;
import static org.atlanmod.commons.Preconditions.checkNotNull; import static org.atlanmod.commons.Preconditions.checkNotNull;
public abstract class Event { public abstract class Event {
private String id; protected String id;
private Period slot; protected Period slot;
public String getId() { public String getId() {
return id; return id;
} }
public void setId(String id) { public void setId(@NonNull String id) {
checkNotNull(id); checkNotNull(id);
this.id = id; this.id = id;
} }
public void setSlot(Period slot){ public Period getSlot() {
return slot;
}
public void setSlot(Period slot) {
checkNotNull(slot); checkNotNull(slot);
this.slot = slot; this.slot = slot;
} }
public abstract boolean conflictsWith(Event other);
public abstract boolean conflictsWithSingleEvent(SingleEvent other);
public abstract boolean conflictsWithRecurrentEvent(RecurrentEvent other);
} }
package fr.unantes.l3.construction.events;
import fr.unantes.l3.construction.exercice10.Interval;
import java.util.Date;
public class Period extends Interval<Date> {
public Period(Date begin, Date end) {
super(begin, end);
}
}
package fr.unantes.l3.construction.events;
import java.util.Collection;
import java.util.LinkedList;
public class RecurrentEvent extends Event {
@Override
public boolean conflictsWith(Event other) {
return other.conflictsWithRecurrentEvent(this);
}
@Override
public boolean conflictsWithSingleEvent(SingleEvent other) {
for (Period each: this.occurrences()) {
if (each.overlaps(other.slot)) {
return true;
}
}
return false;
}
@Override
public boolean conflictsWithRecurrentEvent(RecurrentEvent other) {
for (Period each : this.occurrences()) {
for (Period period : other.occurrences()) {
if (each.overlaps(period)) {
return true;
}
}
}
return false;
}
private Collection<Period> occurrences() {
Collection<Period> calculatedOcurrences = new LinkedList<>();
// TODO
return calculatedOcurrences;
}
}
package fr.unantes.l3.construction.events;
public class SingleEvent extends Event {
@Override
public boolean conflictsWith(Event other) {
return other.conflictsWithSingleEvent(this);
}
@Override
public boolean conflictsWithSingleEvent(SingleEvent other) {
return other.slot.overlaps(this.slot);
}
@Override
public boolean conflictsWithRecurrentEvent(RecurrentEvent other) {
return false;
}
}
package fr.unantes.l3.construction.refactorings;
public class ArrayList {
private Object[] elements = new Object[10];
private boolean readOnly;
private int size = 0;
public void add(Object child) {
if (readOnly) {
return;
}
int newSize = size + 1;
if (newSize > elements.length) {
Object[] newElements = new Object[elements.length + 10];
for (int i = 0; i < size; i++) {
newElements[i] = elements[i];
}
elements = newElements;
}
elements[size] = child;
size++;
}
public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
}
public boolean isReadOnly() {
return readOnly;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment