Class Event

java.lang.Object
  extended by Event

public class Event
extends java.lang.Object

An Event object has a description, the days of the week on which it occurs, a start time, and an end time. For example, an Event in a university course scheduling application might be a lecture that occurs on Monday, Wednesday and Friday from 9:00 to 9:50. As another example, an Event in a digital video recorder application might be a show that airs on Thursdays from 8:00 to 9:00.

An Event object is immutable. That is, once it is created, its attributes can't be changed.


Constructor Summary
Event(java.lang.String description, java.lang.String days, java.lang.String times)
           Explicit Value Constructor
 
Method Summary
 boolean conflicts(Event other)
          Return true if this Event conflicts/overlaps with the Event named other.
 java.lang.String toString()
          Returns a String representation of this Event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Event

public Event(java.lang.String description,
             java.lang.String days,
             java.lang.String times)
      throws java.lang.IllegalArgumentException

Explicit Value Constructor

For convenience, this constructor is passed String parameters. If there are problems with the parameters, this constructor will throw an IllegalArgumentException.

If the Event occurs on more than one day, the individual days must be comma-delimited (e.g., "M,W,F"). A day can be spelled-out or abbreviated. If an abbreviation is ambiguous (e.g., "T") the earliest match will be used (e.g., "Tuesday" for "T").

The start and end times of the Event must be formatted as hh:mm-hh:mm and the end time must not be before the start time.

Parameters:
description - The description of the Event
days - The days of the Event (comma delimited)
times - The times of the Event (hh:mm-hh:mm)
Throws:
java.lang.IllegalArgumentException
Method Detail

conflicts

public boolean conflicts(Event other)
Return true if this Event conflicts/overlaps with the Event named other. For example, there is a conflict when other and this both include Wednesday and other.start is between this.start and this.end

Parameters:
other - The other Event to consider
Returns:
true if there is a conflict; false otherwise

toString

public java.lang.String toString()
Returns a String representation of this Event. The String contains the description, followed by a space, followed by two-day abbreviations of the days (comma-delimited), followed by a space, followed by the start time, followed by a dash, followed by the end time.

Overrides:
toString in class java.lang.Object


James Madison University, Department of Computer Science