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.
VSDriver
application as follows:
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".
Schedule
will never contain more
than 100 Event
objects.
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".
System.in
).
It must recognize and respond to the following commands:
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.
System.in
),
and process the user's response.
The user's response must be in the following format:
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.)
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.
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
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
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