|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.Vector<java.lang.Boolean>
scheduler.generate.DayAvail
public class DayAvail
Represents a Days availability.
| Field Summary |
|---|
| Fields inherited from class java.util.Vector |
|---|
capacityIncrement, elementCount, elementData |
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
DayAvail()
Creates a 48-entry array of availability for a day (one entry for every half-hour in the day). |
|
| Method Summary | |
|---|---|
boolean |
book(Time fakeStart,
Time fakeEnd)
Books a given time range. |
private static java.lang.Object[] |
compute(Time fakeStart,
Time fakeEnd)
For use when iterating through the vector of availability. |
boolean |
isFree(Time fakeStart,
Time fakeEnd)
Determines whether a given span of time is free. |
java.lang.String |
toString()
Simple way to print out the availability of each time slot in the day. |
| Methods inherited from class java.util.Vector |
|---|
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, trimToSize |
| Methods inherited from class java.util.AbstractList |
|---|
iterator, listIterator, listIterator |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
|---|
iterator, listIterator, listIterator |
| Constructor Detail |
|---|
public DayAvail()
Post:
//Size must be 48, for each half hour of the day
this.size() = 48
&&
//Each entry is "true"
for (Boolean b: this)
{
b;
}
| Method Detail |
|---|
public boolean book(Time fakeStart,
Time fakeEnd)
throws EndBeforeStartException
Pre:
//Can't end before it begins
fakeEnd.compareTo(fakeStart) > 0
Post:
// { Only if "isFree" returned true for "fakeStart" and "fakeEnd" } //
//Entries corresponding to the half hour slots between fakeStart and
//fakeEnd (rounded down and rounded up to the nearest half hour,
//respectively) must be asserted. Any other slots should remain as they
//were before the booking
for (int i = 0; i < this.size(); i ++)
{
if (this.get(i) != this'.get(i))
{
startSlot < i < endSlot;
}
}
//See "compute()" for a break down of how "startSlot" and "endSlot"
//are computed and used. The logic is too much to put here.
fakeStart - beginning of the time range (not yet rounded)fakeEnd - end of the time range (not yet rounded)
EndBeforeStartException
public boolean isFree(Time fakeStart,
Time fakeEnd)
throws EndBeforeStartException
Pre:
//Can't end before it starts
fakeEnd.compareTo(fakeStart) > 0
fakeStart - beginning of the time range (not yet rounded)fakeEnd - end of the time range (not yet rounded)
EndBeforeStartException
private static java.lang.Object[] compute(Time fakeStart,
Time fakeEnd)
throws EndBeforeStartException
fakeStart - The start time to modify (round down)fakeEnd - The end time to modif (round up)
EndBeforeStartExceptionpublic java.lang.String toString()
toString in class java.util.Vector<java.lang.Boolean>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||