JMU
logo.png
The VSDriver Class


Introduction

Purpose: The VSDriver class is the "main" class (i.e., it contains a main() method) for a command-line application that can be used to create/display a Schedule of lectures.

Background
About the System: The user must be able to start the VSDriver application as follows:
java VSDriver [title]

where title denotes the title of the Schedule to create. (Note: If the title is omitted, the default title must be the String "VirtualStudent Schedule".

Details
Times:
All times must be 'rounded down' (i.e., truncated) to a time that is evenly divisible by 5 minutes. For example, 9:01 must be truncated to 9:00 and 2:49 must be truncated to 2:45.
Schedule Size:
You can assume that a Schedule will never contain more than 100 Event objects.
Modes of Operation:
The application must support two modes of operation, command mode and create mode.
Prompts:
All prompts must be output to System.out using the format String "%10s: " (note the space after the colon). When in command mode, the application must prompt the user with the String "Command". When in create mode, the application must prompt the user with the String "Event".
Command Mode:
When in command mode, the application must prompt the user for a command and read the user's response (from System.in). It must recognize and respond to the following commands:
create
display
quit

The create command must cause the system to enter create mode, the display command must cause the system to display the current schedule, and the quit command must terminate the application.

If the user enters anything else, the application must output the String "Invalid Command" followed by a newline character.

Create Mode:
When in create mode, the application must prompt the user for an event, read the user's response (from System.in), and process the user's response.

The user's response must be in the following format:

description;day[,day]...;starthour:startminute-endhour:endminute

where description denotes the description of the Event, day denotes a day of the week, starthour represents the hour that the Event starts, startminute represents the minute that the Event starts, endhour represents the hour that the Event ends, and endminute represents the minute that the Event ends. (Note the colon between the minute and hour fields.)

The description may contain any printable character other than ';'.

A day man be any day of the week (e.g., "Monday", "Tuesday") or any abbreviation (e.g., "M", "T"). Abbreviations man be one letter (e.g., "M") or multiple letters (e.g., "Tu", "Th").

Both starthour and endhour must use a "12-hour" clock. Given the way universities schedule courses, the hour must be one of the following values: 8,9,10,11,12,1,2,3,4,5,6,7. The values 8,9,10,11 are all A.M., and the values 12,1,2,3,4,5,6,7 are all P.M.. Both startminute and endminute must be in the interval [0, 59]. In addition, the end time must be after the start time.

If the user enters an event in an incorrect way, the application must respond with an error message (followed by a newline character), as follows:

If the input does not contain all three parts (i.e., a description, one or more days, and times), the error message must be the String "Missing Information".

If the days or times are invalid, the error message must be the String "Bad Information".

If the event information is valid, the application must create a new Event object and attempt to add it to the Schedule. If the Event conflicts/overlaps with an Event that is already in the Schedule, the application must output the String "Conflict" followed by a newline character. (Note: Two Event objects do not conflict/overlap if they have one 'end point' in common. For example, the times 9:00-10:00 and 10:00-11:00 do not conflict/overlap.)

Display Mode:
In response to the display command, the application must output the Schedule object's title, followed by a newline character, followed by the String representation of all of the Event objects in the current Schedule (each of which must be followed by a newline character). If there are no Event objects in the current Schedule, the title line must be followed by the String "No Scheduled Events" and a newline character.

The application must then immediately enter command mode.

Examples
A Simple Example:
The following example illustrates the use of this application:
java VSDriver "A Simple Schedule"
   Command: create
     Event: GSCI103;t,th;10:00-11:15
   Command: create
     Event: ENG220;monday,wed,f;8:00-8:50
   Command: display
A Simple Schedule
GSCI103 Tu,Th 10:00-11:15
ENG220 Mo,We,Fr 08:00-08:50
   Command: quit
An Example with Time Issues:
The following example illustrates some of the time-handling features of this application:
java VSDriver Times
   Command: create
     Event: Rounding;m;8:01-8:54
   Command: display
Times
Rounding Mo 08:00-08:50
   Command: create
     Event: Bad;f;9:00-8:00
Bad Information
   Command: create
     Event: Overlap;m;8:30-9:00
Conflict
   Command: quit
An Example with Error Messages:
The following example illustrates some of the error handling:
java VSDriver "Lynwood Rose's Schedule"
   Command: create
     Event: CS239 Lecture;tu,th;8:00-9:15
   Command: create
     Event: CS239 Lab;m,w;8:00-8:50
   Command: delete
Invalid Command
   Command: create
     Event: CS227;t,thursday;9:30-10:45
   Command: Math235;m,w,f;10-11:00
Invalid Command
   Command: create
     Event: Math235;m,w,f;10-11:00
Bad Information
   Command: create
     Event: Math235;m,w,f;10:10-11:00
   Command: display
Lynwood Rose's Schedule
CS239 Lecture Tu,Th 08:00-09:15
CS239 Lab Mo,We 08:00-08:50
CS227 Tu,Th 09:30-10:45
Math235 Mo,We,Fr 10:10-11:00
   Command: create
     Event: Phys105;m,w,f;11:15-12:05
   Command: display
Lynwood Rose's Schedule
CS239 Lecture Tu,Th 08:00-09:15
CS239 Lab Mo,We 08:00-08:50
CS227 Tu,Th 09:30-10:45
Math235 Mo,We,Fr 10:10-11:00
Phys105 Mo,We,Fr 11:15-12:05
   Command: quit

Copyright 2011